1 // -----------------------------------------------------------------------
\r
2 // Copyright (c) Microsoft Corporation. All rights reserved.
\r
3 // -----------------------------------------------------------------------
\r
5 using System.Collections.Generic;
\r
7 namespace Microsoft.Internal.Collections
\r
9 public static class DictionaryExtensions
\r
11 public static bool ContainsAllKeys<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, IEnumerable<TKey> keys)
\r
13 foreach (TKey key in keys)
\r
15 if (!dictionary.ContainsKey(key))
\r
22 public static bool DictionaryEquals<TKey, TValue>(this IDictionary<TKey, TValue> dictionary1, IDictionary<TKey, TValue> dictionary2)
\r
24 if (dictionary1.Keys.Count != dictionary2.Keys.Count)
\r
29 foreach (KeyValuePair<TKey, TValue> kvp in dictionary1)
\r
31 TValue value1 = kvp.Value;
\r
32 TValue value2 = default(TValue);
\r
33 if (!dictionary2.TryGetValue(kvp.Key, out value2))
\r
38 IDictionary<TKey, TValue> nestedDictionary1 = value1 as IDictionary<TKey, TValue>;
\r
39 IDictionary<TKey, TValue> nestedDictionary2 = value1 as IDictionary<TKey, TValue>;
\r
41 if ((nestedDictionary1 != null) && (nestedDictionary2 != null))
\r
43 if (!nestedDictionary1.DictionaryEquals(nestedDictionary2))
\r
50 if (!(value1.Equals(value2)))
\r