private static void EquatableEnumerableAdd <T>(List <PairAndValueComparer <string, object> > dictionary, string jsonText, IEnumerable <T> actualObject) where T : IEquatable <T> { object value = actualObject; Func <IEnumerable <T>, IEnumerable <T>, bool> comparer = (x, y) => x.SafeEquals(y, (a, b) => a.Equals(b)); Func <object, object, bool> castedComparer = (x, y) => comparer((x as IEnumerable).Cast <T>(), (y as IEnumerable).Cast <T>()); var obj = new PairAndValueComparer <string, object> { Key = jsonText, Value = actualObject, Comparer = castedComparer }; dictionary.Add(obj); }
private static void EquatableEnumerableAdd <T>(List <PairAndValueComparer <string, object> > dictionary, string jsonText, IEnumerable <T> actualObject, IEqualityComparer <T> baseComparer) { object value = actualObject; Func <IEnumerable <T>, IEnumerable <T>, bool> comparer = (x, y) => x.SafeEquals(y, (a, b) => baseComparer.Equals(a, b)); Func <object, object, bool> castedComparer = (x, y) => comparer((IEnumerable <T>)x, (IEnumerable <T>)y); var obj = new PairAndValueComparer <string, object> { Key = jsonText, Value = actualObject, Comparer = castedComparer }; dictionary.Add(obj); }