12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- namespace wf
- {
- public class ReadOnlyDictionary<Tkey, TVal> : IEnumerable<KeyValuePair<Tkey, TVal>>, IEnumerable
- {
- public ReadOnlyDictionary(Dictionary<Tkey, TVal> srcData)
- {
- this.srcData = srcData;
- }
- public TVal this[Tkey key]
- {
- get
- {
- return this.Get(key);
- }
- }
- public int Count
- {
- get
- {
- return this.srcData.Count;
- }
- }
- public bool ContainsKey(Tkey key)
- {
- return this.srcData.ContainsKey(key);
- }
- public TVal Get(Tkey key)
- {
- return this.srcData[key];
- }
- public Tkey[] GetKeyArray()
- {
- Tkey[] array = new Tkey[this.srcData.Count];
- int num = 0;
- foreach (KeyValuePair<Tkey, TVal> keyValuePair in this.srcData)
- {
- array[num++] = keyValuePair.Key;
- }
- return array;
- }
- public TVal[] GetValueArray()
- {
- TVal[] array = new TVal[this.srcData.Count];
- int num = 0;
- foreach (KeyValuePair<Tkey, TVal> keyValuePair in this.srcData)
- {
- array[num++] = keyValuePair.Value;
- }
- return array;
- }
- public Dictionary<Tkey, TVal> Copy()
- {
- return new Dictionary<Tkey, TVal>(this.srcData);
- }
- public IEnumerator<KeyValuePair<Tkey, TVal>> GetEnumerator()
- {
- return this.srcData.GetEnumerator();
- }
- IEnumerator IEnumerable.GetEnumerator()
- {
- return this.srcData.GetEnumerator();
- }
- private Dictionary<Tkey, TVal> srcData;
- }
- }
|