using System; using System.Collections.Generic; using System.Diagnostics; namespace Cryville.Common.Collections.Generic { [DebuggerDisplay("Count = {Count}"), DebuggerTypeProxy(typeof(PairListDebugView<,>))] public class PairList : List>, IPairList, 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"); } } } internal class PairListDebugView { readonly PairList _self; public PairListDebugView(PairList self) { _self = self; } [DebuggerBrowsable(DebuggerBrowsableState.RootHidden)] public KeyValuePair[] Items { get { KeyValuePair[] array = new KeyValuePair[_self.Count]; _self.CopyTo(array, 0); return array; } } } }