Remove excessive shortcut key matching in ToolStrip
[mono.git] / mcs / class / System.ComponentModel.Composition / Tests / UnitTestFramework / System / Collections / Generic / DictionaryExtensions.cs
1 // -----------------------------------------------------------------------\r
2 // Copyright (c) Microsoft Corporation.  All rights reserved.\r
3 // -----------------------------------------------------------------------\r
4 using System;\r
5 using System.Collections.Generic;\r
6 \r
7 namespace Microsoft.Internal.Collections\r
8 {\r
9     public static class DictionaryExtensions\r
10     {\r
11         public static bool ContainsAllKeys<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, IEnumerable<TKey> keys)\r
12         {\r
13             foreach (TKey key in keys)\r
14             {\r
15                 if (!dictionary.ContainsKey(key))\r
16                     return false;\r
17             }\r
18 \r
19             return true;\r
20         }\r
21 \r
22         public static bool DictionaryEquals<TKey, TValue>(this IDictionary<TKey, TValue> dictionary1, IDictionary<TKey, TValue> dictionary2)\r
23         {\r
24             if (dictionary1.Keys.Count != dictionary2.Keys.Count)\r
25             {\r
26                 return false;\r
27             }\r
28 \r
29             foreach (KeyValuePair<TKey, TValue> kvp in dictionary1)\r
30             {\r
31                 TValue value1 = kvp.Value;\r
32                 TValue value2 = default(TValue);\r
33                 if (!dictionary2.TryGetValue(kvp.Key, out value2))\r
34                 {\r
35                     return false;\r
36                 }\r
37 \r
38                 IDictionary<TKey, TValue> nestedDictionary1 = value1 as IDictionary<TKey, TValue>;\r
39                 IDictionary<TKey, TValue> nestedDictionary2 = value1 as IDictionary<TKey, TValue>;\r
40 \r
41                 if ((nestedDictionary1 != null) && (nestedDictionary2 != null))\r
42                 {\r
43                     if (!nestedDictionary1.DictionaryEquals(nestedDictionary2))\r
44                     {\r
45                         return false;\r
46                     }\r
47                 }\r
48                 else\r
49                 {\r
50                     if (!(value1.Equals(value2)))\r
51                     {\r
52                         return false;\r
53                     }\r
54                 }\r
55             }\r
56 \r
57             return true;\r
58         }\r
59     }\r
60 }