using System; using System.Collections; using System.Collections.Generic; namespace wf { public class ReadOnlyDictionary : IEnumerable>, IEnumerable { public ReadOnlyDictionary(Dictionary 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 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 keyValuePair in this.srcData) { array[num++] = keyValuePair.Value; } return array; } public Dictionary Copy() { return new Dictionary(this.srcData); } public IEnumerator> GetEnumerator() { return this.srcData.GetEnumerator(); } IEnumerator IEnumerable.GetEnumerator() { return this.srcData.GetEnumerator(); } private Dictionary srcData; } }