Implement MachineKey.Protect and MachineKey.Unprotect
[mono.git] / mcs / class / System.ComponentModel.Composition / src / ComponentModel / Microsoft / Internal / Collections / ReadOnlyDictionary.cs
1 // -----------------------------------------------------------------------\r
2 // Copyright (c) Microsoft Corporation.  All rights reserved.\r
3 // -----------------------------------------------------------------------\r
4 using System;\r
5 using System.Collections;\r
6 using System.Collections.Generic;\r
7 using System.Diagnostics;\r
8 \r
9 namespace Microsoft.Internal.Collections\r
10 {\r
11     [DebuggerDisplay("Count = {Count}")]\r
12     [DebuggerTypeProxy(typeof(ReadOnlyDictionaryDebuggerProxy<,>))]\r
13     internal sealed partial class ReadOnlyDictionary<TKey, TValue> : IDictionary<TKey, TValue>\r
14     {\r
15         private readonly IDictionary<TKey, TValue> _innerDictionary;\r
16 \r
17         public ReadOnlyDictionary(IDictionary<TKey, TValue> dictionary)\r
18         {\r
19             this._innerDictionary = dictionary ?? new Dictionary<TKey, TValue>(0);\r
20         }\r
21 \r
22         public int Count\r
23         {\r
24             get { return this._innerDictionary.Count; }\r
25         }\r
26 \r
27         public bool IsReadOnly\r
28         {\r
29             get { return true; }\r
30         }\r
31 \r
32         public ICollection<TKey> Keys\r
33         {\r
34             get { return this._innerDictionary.Keys; }\r
35         }\r
36 \r
37         public TValue this[TKey key]\r
38         {\r
39             get { return this._innerDictionary[key]; }\r
40             set { throw new NotSupportedException(Strings.NotSupportedReadOnlyDictionary); }\r
41         }\r
42 \r
43         public ICollection<TValue> Values\r
44         {\r
45             get { return this._innerDictionary.Values; }\r
46         }\r
47 \r
48         public bool Contains(KeyValuePair<TKey, TValue> item)\r
49         {\r
50             return this._innerDictionary.Contains(item);\r
51         }\r
52 \r
53         public bool ContainsKey(TKey key)\r
54         {\r
55             return this._innerDictionary.ContainsKey(key);\r
56         }\r
57 \r
58         public void CopyTo(KeyValuePair<TKey, TValue>[] array, int arrayIndex)\r
59         {\r
60             this._innerDictionary.CopyTo(array, arrayIndex);\r
61         }\r
62 \r
63         public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator()\r
64         {\r
65             return this._innerDictionary.GetEnumerator();\r
66         }\r
67 \r
68         public bool TryGetValue(TKey key, out TValue value)\r
69         {\r
70             return this._innerDictionary.TryGetValue(key, out value);\r
71         }\r
72 \r
73         IEnumerator IEnumerable.GetEnumerator()\r
74         {\r
75             return this._innerDictionary.GetEnumerator();\r
76         }\r
77 \r
78         void IDictionary<TKey, TValue>.Add(TKey key, TValue value)\r
79         {\r
80             throw new NotSupportedException(Strings.NotSupportedReadOnlyDictionary);\r
81         }\r
82 \r
83         void ICollection<KeyValuePair<TKey, TValue>>.Add(KeyValuePair<TKey, TValue> item)\r
84         {\r
85             throw new NotSupportedException(Strings.NotSupportedReadOnlyDictionary);\r
86         }\r
87 \r
88         void ICollection<KeyValuePair<TKey, TValue>>.Clear()\r
89         {\r
90             throw new NotSupportedException(Strings.NotSupportedReadOnlyDictionary);\r
91         }\r
92 \r
93         bool IDictionary<TKey, TValue>.Remove(TKey key)\r
94         {\r
95             throw new NotSupportedException(Strings.NotSupportedReadOnlyDictionary);\r
96         }\r
97 \r
98         bool ICollection<KeyValuePair<TKey, TValue>>.Remove(KeyValuePair<TKey, TValue> item)\r
99         {\r
100             throw new NotSupportedException(Strings.NotSupportedReadOnlyDictionary);\r
101         }\r
102     }\r
103 }\r