// Needed for Workaround #if !NET_4_6 using System; using System.Collections.Generic; using LinqInternal.Core; namespace LinqInternal.Collections.Specialized { [System.Diagnostics.DebuggerNonUserCode] internal class CustomEqualityComparer : IEqualityComparer { private readonly Func _comparison; private readonly Func _getHashCode; public CustomEqualityComparer(Func comparison, Func getHashCode) { if (comparison == null) { throw new ArgumentNullException("comparison"); } if (getHashCode == null) { throw new ArgumentNullException("getHashCode"); } _comparison = comparison; _getHashCode = getHashCode; } public CustomEqualityComparer(IComparer comparer, Func getHashCode) { if (comparer == null) { throw new ArgumentNullException("comparer"); } if (getHashCode == null) { throw new ArgumentNullException("getHashCode"); } _comparison = (x, y) => comparer.Compare(x, y) == 0; _getHashCode = getHashCode; } public CustomEqualityComparer(Func comparison, Func getHashCode) { if (comparison == null) { throw new ArgumentNullException("comparison"); } if (getHashCode == null) { throw new ArgumentNullException("getHashCode"); } _comparison = (x, y) => comparison.Invoke(x, y) == 0; _getHashCode = getHashCode; } public CustomEqualityComparer(Comparison comparison, Func getHashCode) { if (comparison == null) { throw new ArgumentNullException("comparison"); } if (getHashCode == null) { throw new ArgumentNullException("getHashCode"); } _comparison = (x, y) => comparison.Invoke(x, y) == 0; _getHashCode = getHashCode; } public bool Equals(T x, T y) { return _comparison.Invoke(x, y); } public int GetHashCode(T obj) { return _getHashCode.Invoke(obj); } } } #endif