~ubuntu-branches/ubuntu/trusty/smuxi/trusty-proposed

« back to all changes in this revision

Viewing changes to lib/Newtonsoft.Json/Src/Newtonsoft.Json/Utilities/DictionaryWrapper.cs

  • Committer: Package Import Robot
  • Author(s): Mirco Bauer
  • Date: 2013-05-25 22:11:31 UTC
  • mfrom: (1.2.12)
  • Revision ID: package-import@ubuntu.com-20130525221131-nd2mc0kzubuwyx20
Tags: 0.8.11-1
* [22d13d5] Imported Upstream version 0.8.11
* [6d2b95a] Refreshed patches
* [89eb66e] Added ServiceStack libraries to smuxi-engine package
* [848ab10] Enable Campfire engine
* [c6dbdc7] Always build db4o for predictable build result
* [13ec489] Exclude OS X specific libraries from dh_clideps

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
using System;
2
 
using System.Collections.Generic;
3
 
using System.Linq;
4
 
using System.Text;
5
 
using System.Collections;
6
 
using System.Threading;
7
 
 
8
 
namespace Newtonsoft.Json.Utilities
9
 
{
10
 
  internal interface IWrappedDictionary : IDictionary
11
 
  {
12
 
    object UnderlyingDictionary { get; }
13
 
  }
14
 
 
15
 
  internal class DictionaryWrapper<TKey, TValue> : IDictionary<TKey, TValue>, IWrappedDictionary
16
 
  {
17
 
    private readonly IDictionary _dictionary;
18
 
    private readonly IDictionary<TKey, TValue> _genericDictionary;
19
 
    private object _syncRoot;
20
 
 
21
 
    public DictionaryWrapper(IDictionary dictionary)
22
 
    {
23
 
      ValidationUtils.ArgumentNotNull(dictionary, "dictionary");
24
 
 
25
 
      _dictionary = dictionary;
26
 
    }
27
 
 
28
 
    public DictionaryWrapper(IDictionary<TKey, TValue> dictionary)
29
 
    {
30
 
      ValidationUtils.ArgumentNotNull(dictionary, "dictionary");
31
 
 
32
 
      _genericDictionary = dictionary;
33
 
    }
34
 
 
35
 
    public void Add(TKey key, TValue value)
36
 
    {
37
 
      if (_genericDictionary != null)
38
 
        _genericDictionary.Add(key, value);
39
 
      else
40
 
        _dictionary.Add(key, value);
41
 
    }
42
 
 
43
 
    public bool ContainsKey(TKey key)
44
 
    {
45
 
      if (_genericDictionary != null)
46
 
        return _genericDictionary.ContainsKey(key);
47
 
      else
48
 
        return _dictionary.Contains(key);
49
 
    }
50
 
 
51
 
    public ICollection<TKey> Keys
52
 
    {
53
 
      get
54
 
      {
55
 
        if (_genericDictionary != null)
56
 
          return _genericDictionary.Keys;
57
 
        else
58
 
          return _dictionary.Keys.Cast<TKey>().ToList();
59
 
      }
60
 
    }
61
 
 
62
 
    public bool Remove(TKey key)
63
 
    {
64
 
      if (_genericDictionary != null)
65
 
      {
66
 
        return _genericDictionary.Remove(key);
67
 
      }
68
 
      else
69
 
      {
70
 
        if (_dictionary.Contains(key))
71
 
        {
72
 
          _dictionary.Remove(key);
73
 
          return true;
74
 
        }
75
 
        else
76
 
        {
77
 
          return false;
78
 
        }
79
 
      }
80
 
    }
81
 
 
82
 
    public bool TryGetValue(TKey key, out TValue value)
83
 
    {
84
 
      if (_genericDictionary != null)
85
 
      {
86
 
        return _genericDictionary.TryGetValue(key, out value);
87
 
      }
88
 
      else
89
 
      {
90
 
        if (!_dictionary.Contains(key))
91
 
        {
92
 
          value = default(TValue);
93
 
          return false;
94
 
        }
95
 
        else
96
 
        {
97
 
          value = (TValue)_dictionary[key];
98
 
          return true;
99
 
        }
100
 
      }
101
 
    }
102
 
 
103
 
    public ICollection<TValue> Values
104
 
    {
105
 
      get
106
 
      {
107
 
        if (_genericDictionary != null)
108
 
          return _genericDictionary.Values;
109
 
        else
110
 
          return _dictionary.Values.Cast<TValue>().ToList();
111
 
      }
112
 
    }
113
 
 
114
 
    public TValue this[TKey key]
115
 
    {
116
 
      get
117
 
      {
118
 
        if (_genericDictionary != null)
119
 
          return _genericDictionary[key];
120
 
        else
121
 
          return (TValue)_dictionary[key];
122
 
      }
123
 
      set
124
 
      {
125
 
        if (_genericDictionary != null)
126
 
          _genericDictionary[key] = value;
127
 
        else
128
 
          _dictionary[key] = value;
129
 
      }
130
 
    }
131
 
 
132
 
    public void Add(KeyValuePair<TKey, TValue> item)
133
 
    {
134
 
      if (_genericDictionary != null)
135
 
        _genericDictionary.Add(item);
136
 
      else
137
 
        ((IList)_dictionary).Add(item);
138
 
    }
139
 
 
140
 
    public void Clear()
141
 
    {
142
 
      if (_genericDictionary != null)
143
 
        _genericDictionary.Clear();
144
 
      else
145
 
        _dictionary.Clear();
146
 
    }
147
 
 
148
 
    public bool Contains(KeyValuePair<TKey, TValue> item)
149
 
    {
150
 
      if (_genericDictionary != null)
151
 
        return _genericDictionary.Contains(item);
152
 
      else
153
 
        return ((IList)_dictionary).Contains(item);
154
 
    }
155
 
 
156
 
    public void CopyTo(KeyValuePair<TKey, TValue>[] array, int arrayIndex)
157
 
    {
158
 
      if (_genericDictionary != null)
159
 
      {
160
 
        _genericDictionary.CopyTo(array, arrayIndex);
161
 
      }
162
 
      else
163
 
      {
164
 
        foreach (DictionaryEntry item in _dictionary)
165
 
        {
166
 
          array[arrayIndex++] = new KeyValuePair<TKey, TValue>((TKey)item.Key, (TValue)item.Value);
167
 
        }
168
 
      }
169
 
    }
170
 
 
171
 
    public int Count
172
 
    {
173
 
      get
174
 
      {
175
 
        if (_genericDictionary != null)
176
 
          return _genericDictionary.Count;
177
 
        else
178
 
          return _dictionary.Count;
179
 
      }
180
 
    }
181
 
 
182
 
    public bool IsReadOnly
183
 
    {
184
 
      get
185
 
      {
186
 
        if (_genericDictionary != null)
187
 
          return _genericDictionary.IsReadOnly;
188
 
        else
189
 
          return _dictionary.IsReadOnly;
190
 
      }
191
 
    }
192
 
 
193
 
    public bool Remove(KeyValuePair<TKey, TValue> item)
194
 
    {
195
 
      if (_genericDictionary != null)
196
 
      {
197
 
        return _genericDictionary.Remove(item);
198
 
      }
199
 
      else
200
 
      {
201
 
        if (_dictionary.Contains(item.Key))
202
 
        {
203
 
          object value = _dictionary[item.Key];
204
 
 
205
 
          if (object.Equals(value, item.Value))
206
 
          {
207
 
            _dictionary.Remove(item.Key);
208
 
            return true;
209
 
          }
210
 
          else
211
 
          {
212
 
            return false;
213
 
          }
214
 
        }
215
 
        else
216
 
        {
217
 
          return true;
218
 
        }
219
 
      }
220
 
    }
221
 
 
222
 
    public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator()
223
 
    {
224
 
      if (_genericDictionary != null)
225
 
        return _genericDictionary.GetEnumerator();
226
 
      else
227
 
        return _dictionary.Cast<DictionaryEntry>().Select(de => new KeyValuePair<TKey, TValue>((TKey)de.Key, (TValue)de.Value)).GetEnumerator();
228
 
    }
229
 
 
230
 
    IEnumerator IEnumerable.GetEnumerator()
231
 
    {
232
 
      return GetEnumerator();
233
 
    }
234
 
 
235
 
    void IDictionary.Add(object key, object value)
236
 
    {
237
 
      if (_genericDictionary != null)
238
 
        _genericDictionary.Add((TKey)key, (TValue)value);
239
 
      else
240
 
        _dictionary.Add(key, value);
241
 
    }
242
 
 
243
 
    bool IDictionary.Contains(object key)
244
 
    {
245
 
      if (_genericDictionary != null)
246
 
        return _genericDictionary.ContainsKey((TKey)key);
247
 
      else
248
 
        return _dictionary.Contains(key);
249
 
    }
250
 
 
251
 
    private struct DictionaryEnumerator<TEnumeratorKey, TEnumeratorValue> : IDictionaryEnumerator
252
 
    {
253
 
      private readonly IEnumerator<KeyValuePair<TEnumeratorKey, TEnumeratorValue>> _e;
254
 
 
255
 
      public DictionaryEnumerator(IEnumerator<KeyValuePair<TEnumeratorKey, TEnumeratorValue>> e)
256
 
      {
257
 
        ValidationUtils.ArgumentNotNull(e, "e");
258
 
        _e = e;
259
 
      }
260
 
 
261
 
      public DictionaryEntry Entry
262
 
      {
263
 
        get { return (DictionaryEntry)Current; }
264
 
      }
265
 
 
266
 
      public object Key
267
 
      {
268
 
        get { return Entry.Key; }
269
 
      }
270
 
 
271
 
      public object Value
272
 
      {
273
 
        get { return Entry.Value; }
274
 
      }
275
 
 
276
 
      public object Current
277
 
      {
278
 
        get { return new DictionaryEntry(_e.Current.Key, _e.Current.Value); }
279
 
      }
280
 
 
281
 
      public bool MoveNext()
282
 
      {
283
 
        return _e.MoveNext();
284
 
      }
285
 
 
286
 
      public void Reset()
287
 
      {
288
 
        _e.Reset();
289
 
      }
290
 
    }
291
 
 
292
 
    IDictionaryEnumerator IDictionary.GetEnumerator()
293
 
    {
294
 
      if (_genericDictionary != null)
295
 
        return new DictionaryEnumerator<TKey, TValue>(_genericDictionary.GetEnumerator());
296
 
      else
297
 
        return _dictionary.GetEnumerator();
298
 
    }
299
 
 
300
 
    bool IDictionary.IsFixedSize
301
 
    {
302
 
      get
303
 
      {
304
 
        if (_genericDictionary != null)
305
 
          return false;
306
 
        else
307
 
          return _dictionary.IsFixedSize;
308
 
      }
309
 
    }
310
 
 
311
 
    ICollection IDictionary.Keys
312
 
    {
313
 
      get
314
 
      {
315
 
        if (_genericDictionary != null)
316
 
          return _genericDictionary.Keys.ToList();
317
 
        else
318
 
          return _dictionary.Keys;
319
 
      }
320
 
    }
321
 
 
322
 
    public void Remove(object key)
323
 
    {
324
 
      if (_genericDictionary != null)
325
 
        _genericDictionary.Remove((TKey)key);
326
 
      else
327
 
        _dictionary.Remove(key);
328
 
    }
329
 
 
330
 
    ICollection IDictionary.Values
331
 
    {
332
 
      get
333
 
      {
334
 
        if (_genericDictionary != null)
335
 
          return _genericDictionary.Values.ToList();
336
 
        else
337
 
          return _dictionary.Values;
338
 
      }
339
 
    }
340
 
 
341
 
    object IDictionary.this[object key]
342
 
    {
343
 
      get
344
 
      {
345
 
        if (_genericDictionary != null)
346
 
          return _genericDictionary[(TKey)key];
347
 
        else
348
 
          return _dictionary[key];
349
 
      }
350
 
      set
351
 
      {
352
 
        if (_genericDictionary != null)
353
 
          _genericDictionary[(TKey)key] = (TValue)value;
354
 
        else
355
 
          _dictionary[key] = value;
356
 
      }
357
 
    }
358
 
 
359
 
    void ICollection.CopyTo(Array array, int index)
360
 
    {
361
 
      if (_genericDictionary != null)
362
 
        _genericDictionary.CopyTo((KeyValuePair<TKey, TValue>[])array, index);
363
 
      else
364
 
        _dictionary.CopyTo(array, index);
365
 
    }
366
 
 
367
 
    bool ICollection.IsSynchronized
368
 
    {
369
 
      get
370
 
      {
371
 
        if (_genericDictionary != null)
372
 
          return false;
373
 
        else
374
 
          return _dictionary.IsSynchronized;
375
 
      }
376
 
    }
377
 
 
378
 
    object ICollection.SyncRoot
379
 
    {
380
 
      get
381
 
      {
382
 
        if (_syncRoot == null)
383
 
          Interlocked.CompareExchange(ref _syncRoot, new object(), null);
384
 
 
385
 
        return _syncRoot;
386
 
      }
387
 
    }
388
 
 
389
 
    public object UnderlyingDictionary
390
 
    {
391
 
      get
392
 
      {
393
 
        if (_genericDictionary != null)
394
 
          return _genericDictionary;
395
 
        else
396
 
          return _dictionary;
397
 
      }
398
 
    }
399
 
  }
400
 
}
 
1
#region License
 
2
// Copyright (c) 2007 James Newton-King
 
3
//
 
4
// Permission is hereby granted, free of charge, to any person
 
5
// obtaining a copy of this software and associated documentation
 
6
// files (the "Software"), to deal in the Software without
 
7
// restriction, including without limitation the rights to use,
 
8
// copy, modify, merge, publish, distribute, sublicense, and/or sell
 
9
// copies of the Software, and to permit persons to whom the
 
10
// Software is furnished to do so, subject to the following
 
11
// conditions:
 
12
//
 
13
// The above copyright notice and this permission notice shall be
 
14
// included in all copies or substantial portions of the Software.
 
15
//
 
16
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 
17
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
 
18
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 
19
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 
20
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 
21
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 
22
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 
23
// OTHER DEALINGS IN THE SOFTWARE.
 
24
#endregion
 
25
 
 
26
using System;
 
27
using System.Collections.Generic;
 
28
using System.Collections;
 
29
using System.Threading;
 
30
#if NET20
 
31
using Newtonsoft.Json.Utilities.LinqBridge;
 
32
#else
 
33
using System.Linq;
 
34
#endif
 
35
 
 
36
namespace Newtonsoft.Json.Utilities
 
37
{
 
38
  internal interface IWrappedDictionary
 
39
    : IDictionary
 
40
  {
 
41
    object UnderlyingDictionary { get; }
 
42
  }
 
43
 
 
44
  internal class DictionaryWrapper<TKey, TValue> : IDictionary<TKey, TValue>, IWrappedDictionary
 
45
  {
 
46
    private readonly IDictionary _dictionary;
 
47
    private readonly IDictionary<TKey, TValue> _genericDictionary;
 
48
    private object _syncRoot;
 
49
 
 
50
    public DictionaryWrapper(IDictionary dictionary)
 
51
    {
 
52
      ValidationUtils.ArgumentNotNull(dictionary, "dictionary");
 
53
 
 
54
      _dictionary = dictionary;
 
55
    }
 
56
 
 
57
    public DictionaryWrapper(IDictionary<TKey, TValue> dictionary)
 
58
    {
 
59
      ValidationUtils.ArgumentNotNull(dictionary, "dictionary");
 
60
 
 
61
      _genericDictionary = dictionary;
 
62
    }
 
63
 
 
64
    public void Add(TKey key, TValue value)
 
65
    {
 
66
      if (_dictionary != null)
 
67
        _dictionary.Add(key, value);
 
68
      else
 
69
        _genericDictionary.Add(key, value);
 
70
    }
 
71
 
 
72
    public bool ContainsKey(TKey key)
 
73
    {
 
74
      if (_dictionary != null)
 
75
        return _dictionary.Contains(key);
 
76
      else
 
77
        return _genericDictionary.ContainsKey(key);
 
78
    }
 
79
 
 
80
    public ICollection<TKey> Keys
 
81
    {
 
82
      get
 
83
      {
 
84
        if (_dictionary != null)
 
85
          return _dictionary.Keys.Cast<TKey>().ToList();
 
86
        else
 
87
          return _genericDictionary.Keys;
 
88
      }
 
89
    }
 
90
 
 
91
    public bool Remove(TKey key)
 
92
    {
 
93
      if (_dictionary != null)
 
94
      {
 
95
        if (_dictionary.Contains(key))
 
96
        {
 
97
          _dictionary.Remove(key);
 
98
          return true;
 
99
        }
 
100
        else
 
101
        {
 
102
          return false;
 
103
        }
 
104
      }
 
105
 
 
106
      return _genericDictionary.Remove(key);
 
107
    }
 
108
 
 
109
    public bool TryGetValue(TKey key, out TValue value)
 
110
    {
 
111
      if (_dictionary != null)
 
112
      {
 
113
        if (!_dictionary.Contains(key))
 
114
        {
 
115
          value = default(TValue);
 
116
          return false;
 
117
        }
 
118
        else
 
119
        {
 
120
          value = (TValue)_dictionary[key];
 
121
          return true;
 
122
        }
 
123
      }
 
124
 
 
125
      return _genericDictionary.TryGetValue(key, out value);
 
126
    }
 
127
 
 
128
    public ICollection<TValue> Values
 
129
    {
 
130
      get
 
131
      {
 
132
        if (_dictionary != null)
 
133
          return _dictionary.Values.Cast<TValue>().ToList();
 
134
        else
 
135
          return _genericDictionary.Values;
 
136
      }
 
137
    }
 
138
 
 
139
    public TValue this[TKey key]
 
140
    {
 
141
      get
 
142
      {
 
143
        if (_dictionary != null)
 
144
          return (TValue)_dictionary[key];
 
145
        return _genericDictionary[key];
 
146
      }
 
147
      set
 
148
      {
 
149
        if (_dictionary != null)
 
150
          _dictionary[key] = value;
 
151
        else
 
152
          _genericDictionary[key] = value;
 
153
      }
 
154
    }
 
155
 
 
156
    public void Add(KeyValuePair<TKey, TValue> item)
 
157
    {
 
158
      if (_dictionary != null)
 
159
        ((IList)_dictionary).Add(item);
 
160
      else
 
161
        _genericDictionary.Add(item);
 
162
    }
 
163
 
 
164
    public void Clear()
 
165
    {
 
166
      if (_dictionary != null)
 
167
        _dictionary.Clear();
 
168
      else
 
169
        _genericDictionary.Clear();
 
170
    }
 
171
 
 
172
    public bool Contains(KeyValuePair<TKey, TValue> item)
 
173
    {
 
174
      if (_dictionary != null)
 
175
        return ((IList)_dictionary).Contains(item);
 
176
      else
 
177
        return _genericDictionary.Contains(item);
 
178
    }
 
179
 
 
180
    public void CopyTo(KeyValuePair<TKey, TValue>[] array, int arrayIndex)
 
181
    {
 
182
      if (_dictionary != null)
 
183
      {
 
184
        foreach (DictionaryEntry item in _dictionary)
 
185
        {
 
186
          array[arrayIndex++] = new KeyValuePair<TKey, TValue>((TKey)item.Key, (TValue)item.Value);
 
187
        }
 
188
      }
 
189
      else
 
190
      {
 
191
        _genericDictionary.CopyTo(array, arrayIndex);
 
192
      }
 
193
    }
 
194
 
 
195
    public int Count
 
196
    {
 
197
      get
 
198
      {
 
199
        if (_dictionary != null)
 
200
          return _dictionary.Count;
 
201
        else
 
202
          return _genericDictionary.Count;
 
203
      }
 
204
    }
 
205
 
 
206
    public bool IsReadOnly
 
207
    {
 
208
      get
 
209
      {
 
210
        if (_dictionary != null)
 
211
          return _dictionary.IsReadOnly;
 
212
        else
 
213
          return _genericDictionary.IsReadOnly;
 
214
      }
 
215
    }
 
216
 
 
217
    public bool Remove(KeyValuePair<TKey, TValue> item)
 
218
    {
 
219
      if (_dictionary != null)
 
220
      {
 
221
        if (_dictionary.Contains(item.Key))
 
222
        {
 
223
          object value = _dictionary[item.Key];
 
224
 
 
225
          if (object.Equals(value, item.Value))
 
226
          {
 
227
            _dictionary.Remove(item.Key);
 
228
            return true;
 
229
          }
 
230
          else
 
231
          {
 
232
            return false;
 
233
          }
 
234
        }
 
235
        else
 
236
        {
 
237
          return true;
 
238
        }
 
239
      }
 
240
      else
 
241
      {
 
242
        return _genericDictionary.Remove(item);
 
243
      }
 
244
    }
 
245
 
 
246
    public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator()
 
247
    {
 
248
      if (_dictionary != null)
 
249
        return _dictionary.Cast<DictionaryEntry>().Select(de => new KeyValuePair<TKey, TValue>((TKey)de.Key, (TValue)de.Value)).GetEnumerator();
 
250
      else
 
251
        return _genericDictionary.GetEnumerator();
 
252
    }
 
253
 
 
254
    IEnumerator IEnumerable.GetEnumerator()
 
255
    {
 
256
      return GetEnumerator();
 
257
    }
 
258
 
 
259
    void IDictionary.Add(object key, object value)
 
260
    {
 
261
      if (_dictionary != null)
 
262
        _dictionary.Add(key, value);
 
263
      else
 
264
        _genericDictionary.Add((TKey)key, (TValue)value);
 
265
    }
 
266
 
 
267
    object IDictionary.this[object key]
 
268
    {
 
269
      get
 
270
      {
 
271
        if (_dictionary != null)
 
272
          return _dictionary[key];
 
273
        else
 
274
          return _genericDictionary[(TKey)key];
 
275
      }
 
276
      set
 
277
      {
 
278
        if (_dictionary != null)
 
279
          _dictionary[key] = value;
 
280
        else
 
281
          _genericDictionary[(TKey)key] = (TValue)value;
 
282
      }
 
283
    }
 
284
 
 
285
    private struct DictionaryEnumerator<TEnumeratorKey, TEnumeratorValue> : IDictionaryEnumerator
 
286
    {
 
287
      private readonly IEnumerator<KeyValuePair<TEnumeratorKey, TEnumeratorValue>> _e;
 
288
 
 
289
      public DictionaryEnumerator(IEnumerator<KeyValuePair<TEnumeratorKey, TEnumeratorValue>> e)
 
290
      {
 
291
        ValidationUtils.ArgumentNotNull(e, "e");
 
292
        _e = e;
 
293
      }
 
294
 
 
295
      public DictionaryEntry Entry
 
296
      {
 
297
        get { return (DictionaryEntry)Current; }
 
298
      }
 
299
 
 
300
      public object Key
 
301
      {
 
302
        get { return Entry.Key; }
 
303
      }
 
304
 
 
305
      public object Value
 
306
      {
 
307
        get { return Entry.Value; }
 
308
      }
 
309
 
 
310
      public object Current
 
311
      {
 
312
        get { return new DictionaryEntry(_e.Current.Key, _e.Current.Value); }
 
313
      }
 
314
 
 
315
      public bool MoveNext()
 
316
      {
 
317
        return _e.MoveNext();
 
318
      }
 
319
 
 
320
      public void Reset()
 
321
      {
 
322
        _e.Reset();
 
323
      }
 
324
    }
 
325
 
 
326
    IDictionaryEnumerator IDictionary.GetEnumerator()
 
327
    {
 
328
      if (_dictionary != null)
 
329
        return _dictionary.GetEnumerator();
 
330
      else
 
331
        return new DictionaryEnumerator<TKey, TValue>(_genericDictionary.GetEnumerator());
 
332
    }
 
333
 
 
334
    bool IDictionary.Contains(object key)
 
335
    {
 
336
      if (_genericDictionary != null)
 
337
        return _genericDictionary.ContainsKey((TKey)key);
 
338
      else
 
339
        return _dictionary.Contains(key);
 
340
    }
 
341
 
 
342
    bool IDictionary.IsFixedSize
 
343
    {
 
344
      get
 
345
      {
 
346
        if (_genericDictionary != null)
 
347
          return false;
 
348
        else
 
349
          return _dictionary.IsFixedSize;
 
350
      }
 
351
    }
 
352
 
 
353
    ICollection IDictionary.Keys
 
354
    {
 
355
      get
 
356
      {
 
357
        if (_genericDictionary != null)
 
358
          return _genericDictionary.Keys.ToList();
 
359
        else
 
360
          return _dictionary.Keys;
 
361
      }
 
362
    }
 
363
 
 
364
    public void Remove(object key)
 
365
    {
 
366
      if (_dictionary != null)
 
367
        _dictionary.Remove(key);
 
368
      else
 
369
        _genericDictionary.Remove((TKey)key);
 
370
    }
 
371
 
 
372
    ICollection IDictionary.Values
 
373
    {
 
374
      get
 
375
      {
 
376
        if (_genericDictionary != null)
 
377
          return _genericDictionary.Values.ToList();
 
378
        else
 
379
          return _dictionary.Values;
 
380
      }
 
381
    }
 
382
 
 
383
    void ICollection.CopyTo(Array array, int index)
 
384
    {
 
385
      if (_dictionary != null)
 
386
        _dictionary.CopyTo(array, index);
 
387
      else
 
388
        _genericDictionary.CopyTo((KeyValuePair<TKey, TValue>[])array, index);
 
389
    }
 
390
 
 
391
    bool ICollection.IsSynchronized
 
392
    {
 
393
      get
 
394
      {
 
395
        if (_dictionary != null)
 
396
          return _dictionary.IsSynchronized;
 
397
        else
 
398
          return false;
 
399
      }
 
400
    }
 
401
 
 
402
    object ICollection.SyncRoot
 
403
    {
 
404
      get
 
405
      {
 
406
        if (_syncRoot == null)
 
407
          Interlocked.CompareExchange(ref _syncRoot, new object(), null);
 
408
 
 
409
        return _syncRoot;
 
410
      }
 
411
    }
 
412
 
 
413
    public object UnderlyingDictionary
 
414
    {
 
415
      get
 
416
      {
 
417
        if (_dictionary != null)
 
418
          return _dictionary;
 
419
        else
 
420
          return _genericDictionary;
 
421
      }
 
422
    }
 
423
  }
 
424
}
 
 
b'\\ No newline at end of file'