/// <summary> /// Adds the specified key. /// </summary> /// <param name="key">The key.</param> /// <param name="item">The item.</param> /// <exception cref="System.Exception">Key already exist</exception> public virtual void Add(string key, T item) { if (_keys.Contains(key)) { throw new Exception("Key already exist"); } _keys.Add(key); int index = _items.Add(item); if (ItemAdd != null) { ItemAdd(this, new KeyedCollectionAddEventArgs(_items[index], index, _keys[index])); } if (CollectionChanged != null) { CollectionChanged(this, new EventArgs()); } }
/// <summary> /// Determines whether [contains] [the specified item]. /// </summary> /// <param name="item">The item.</param> /// <returns><c>true</c> if [contains] [the specified item]; otherwise, <c>false</c>.</returns> public virtual bool Contains(T item) { return(_items.Contains(item)); }