using System; using System.Collections.Generic; namespace Utilities { public partial class KeyValuePairList : List> { public bool ContainsKey(TKey key) { return (this.IndexOfKey(key) != -1); } public int IndexOfKey(TKey key) { for (int index = 0; index < this.Count; index++) { if (this[index].Key.Equals(key)) { return index; } } return -1; } public TValue ValueOf(TKey key) { for (int index = 0; index < this.Count; index++) { if (this[index].Key.Equals(key)) { return this[index].Value; } } return default(TValue); } public void Add(TKey key, TValue value) { this.Add(new KeyValuePair(key, value)); } public List Keys { get { List result = new List(); foreach (KeyValuePair entity in this) { result.Add(entity.Key); } return result; } } public List Values { get { List result = new List(); foreach (KeyValuePair entity in this) { result.Add(entity.Value); } return result; } } } }