示例#1
0
        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)));
        }
示例#2
0
        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))
                       ));
        }
示例#3
0
 static ImmutableKeySet()
 {
     Comparer = EqualityComparerFactory <IImmutableSet <TKey> > .Create((left, right) => left.Overlaps(right) || (left.Empty() && right.Empty()));
 }