using System;
using System.Collections.Generic;
using System.Linq;
namespace MfGames.Gallium
{
public static class JoinEntityExtensions
{
///
/// Merges two sets of entities using the identifier to determine which
/// entities are the same. The `merge` function takes both of the
/// entities with the Entity from the `input` first and the one from
/// `other` second. The returning entity is put into the collection. If
/// an entity from the input is not found in other, then it is just
/// passed on.
///
/// The enumerable of entities to merge to.
/// The collection of entities to merge from.
/// The callback to merge the two.
/// An sequence of entities, merged and unmerged.
public static IEnumerable JoinEntity(
this IEnumerable input,
ICollection other,
Func merge)
{
return input.Join(other, a => a.Id, a => a.Id, merge);
}
}
}