# HG changeset patch # User IBBoard # Date 1303829854 0 # Node ID 80df73deb8fcb242a29e2603bd2f992d98a16c10 # Parent 8022850f7fd7654e7abd8ff681878fdb09e4ab2b Re #48: Collection equality * Swap fixed generic types (from auto-generation) for invocation-selected generic types diff -r 8022850f7fd7 -r 80df73deb8fc Collections/Collections.cs --- a/Collections/Collections.cs Tue Apr 26 14:32:18 2011 +0000 +++ b/Collections/Collections.cs Tue Apr 26 14:57:34 2011 +0000 @@ -12,11 +12,15 @@ { } - public static bool AreEqual(IList list1, IList list2) + public static bool AreEqual (IList list1, IList list2) { bool equal = true; - if (!EqualityChecker.AreEqual(list1, list2)) + if (typeof(T) != typeof(U)) + { + equal = false; + } + else if (!EqualityChecker.AreEqual(list1, list2)) { if (list1.Count != list2.Count) { @@ -40,11 +44,15 @@ return equal; } - public static bool AreEqual(IDictionary dict1, IDictionary dict2) + public static bool AreEqual(IDictionary dict1, IDictionary dict2) where V : class { bool equal = true; - if (!EqualityChecker.AreEqual(dict1, dict2)) + if (typeof(T) != typeof(V) || typeof(U) != typeof(W)) + { + equal = false; + } + else if (!EqualityChecker.AreEqual(dict1, dict2)) { if (dict1.Count != dict2.Count) { @@ -52,9 +60,10 @@ } else { - foreach (KeyValuePair pair in dict1) + foreach (KeyValuePair pair in dict1) { - if (!dict2.ContainsKey(pair.Key) || !EqualityChecker.AreEqual(pair.Value, dict2[pair.Key])) + V key = pair.Key as V; + if (!dict2.ContainsKey(key) || !EqualityChecker.AreEqual(pair.Value, dict2[key])) { equal = false; break;