public static IEquatable <T> AsEquatable <T>([CanBeNull] T obj, [NotNull] Func <T, T, bool> equals) { if (equals == null) { throw new ArgumentNullException(nameof(equals)); } return(new EquatableAdapter <T>(obj, EqualityComparerFactory <T> .Create(equals))); }
public static IEqualityComparer <T> Create <TProjection>(Func <T, TProjection> projection) { var comparer = EqualityComparer <TProjection> .Default; return(EqualityComparerFactory <T> .Create( getHashCode : obj => comparer.GetHashCode(projection(obj)), equals : (x, y) => comparer.Equals(projection(x), projection(y)) )); }
static ImmutableKeySet() { Comparer = EqualityComparerFactory <IImmutableSet <TKey> > .Create((left, right) => left.Overlaps(right) || (left.Empty() && right.Empty())); }