using System; using System.Collections.Generic; namespace Cryville.Common.Collections.Generic { public class PairList : List>, IPairList { public void Add(object key, object value) { Add(new KeyValuePair(key, value)); } public void Insert(int index, object key, object value) { Insert(index, new KeyValuePair(key, value)); } } public class PairList : List>, IPairList { public void Add(TKey key, TValue value) { Add(new KeyValuePair(key, value)); } public void Add(object key, object value) { try { Add((TKey)key, (TValue)value); } catch (InvalidCastException) { throw new ArgumentException("Wrong key type or value type"); } } public void Insert(int index, TKey key, TValue value) { Insert(index, new KeyValuePair(key, value)); } public void Insert(int index, object key, object value) { try { Insert(index, (TKey)key, (TValue)value); } catch (InvalidCastException) { throw new ArgumentException("Wrong key type or value type"); } } } }