/// <summary> /// Finds the specified match. /// </summary> /// <param name="match">The match.</param> /// <returns>LightCollection<TreeItem<T>>.</returns> public LightCollection <TreeItem <T> > Find(Predicate <TreeItem <T> > match) { LightCollection <TreeItem <T> > results = new LightCollection <TreeItem <T> >(); for (int i = 0; i < _globalCollection.Count; i++) { if (match(_globalCollection[i])) { results.Add(_globalCollection[i]); } } return(results); }
/// <summary> /// Adds the specified identifier. /// </summary> /// <param name="id">The identifier.</param> /// <param name="value">The value.</param> /// <returns>TreeItem<T>.</returns> /// <exception cref="System.Exception">key \""+id+"\" already exist</exception> public TreeItem <T> Add(string id, T value) { if (_ownerCollection.GlobalCollection.ContainsKey(id)) { throw new Exception("key \"" + id + "\" already exist"); } TreeItem <T> treeItem = new TreeItem <T>(id, _parent, ref _ownerCollection); _ownerCollection.Global_AddItem(id, treeItem); _items.Add(id); return(treeItem); }
/// <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()); } }