internal static Func <T, int> LoadGetHashCodeDelegate <T>(bool isValueType, bool isObject, StructuralEqualityComparer structuralEqualityComparer) { if (isValueType) { return((value) => EqualityComparer <T> .Default.GetHashCode(value)); } if (isObject) { return((value) => IsValueType(value) ? EqualityComparer <T> .Default.GetHashCode(value) : (value == null ? 0 : structuralEqualityComparer.GetHashCode(value))); } else { return((value) => value == null ? 0 : structuralEqualityComparer.GetHashCode(value)); } }
internal static Func <T, T, bool> LoadEqualsDelegate <T>(bool isValueType, bool isObject, StructuralEqualityComparer structuralEqualityComparer) { if (isValueType) { return((valueA, valueB) => EqualityComparer <T> .Default.Equals(valueA, valueB)); } else if (isObject) { return((valueA, valueB) => IsValueType(valueA) || IsValueType(valueB) ? EqualityComparer <T> .Default.Equals(valueA, valueB) : (valueA == null ? valueB == null : structuralEqualityComparer.Equals(valueA, valueB))); } else // Reference type { return((valueA, valueB) => valueA == null ? valueB == null : structuralEqualityComparer.Equals(valueA, valueB)); } }
internal static Func <T, int> LoadGetHashCodeDelegate <T>(bool isValueType, bool isObject, StructuralEqualityComparer structuralEqualityComparer) { if (isValueType) { return((value) => EqualityComparer <T> .Default.GetHashCode(value !)); // J2N TODO: Note that value can be null here, need to investigate how to override the interface } if (isObject) { return((value) => IsValueType(value) ? EqualityComparer <T> .Default.GetHashCode(value !) : // J2N TODO: Note that value can be null here, need to investigate how to override the interface (value == null ? 0 : structuralEqualityComparer.GetHashCode(value))); } else { return((value) => value == null ? 0 : structuralEqualityComparer.GetHashCode(value)); } }