public virtual void Remove(T aEntry) { CIElement element = CheckValid(aEntry); if (iDictionary.ContainsKey(element.Id)) { iDictionary.Remove(element.Id); } }
protected virtual CIElement CheckValid(T aEntry) { CIElement element = aEntry as CIElement; if (element == null) { throw new NotSupportedException("CIElementDictionary can only contain CIElement derived objects"); } return(element); }
public virtual bool Add(T aEntry) { CIElement element = CheckValid(aEntry); bool needsAdd = iDictionary.ContainsKey(element.Id) == false; if (needsAdd) { iDictionary.Add(element.Id, aEntry); // Treat as though it was added as a child base.OnElementAddedToSelf(element); } return(needsAdd); }
internal override void GetChildrenByType <ChildType>(CIElementList <ChildType> aList, TChildSearchType aType, Predicate <ChildType> aPredicate) { // Get all direct children, and if recusion enabled, then fetch the // entire tree. Type t = typeof(ChildType); foreach (T entry in this) { CIElement element = entry; // if (t.IsAssignableFrom(element.GetType())) { // Get entry of correct type ChildType objectEntry = (ChildType)((object)element); // Check whether it is suitable for inclusion via our predicate bool addEntry = true; if (aPredicate != null) { addEntry = aPredicate(objectEntry); } // Is it okay to take the entry? if (addEntry) { aList.Add(objectEntry); } } // Get the element's children if (aType == TChildSearchType.EEntireHierarchy) { element.GetChildrenByType <ChildType>(aList, aType, aPredicate); } } }
public override bool Contains(CIElement aElement) { return(this.Contains(aElement.Id)); }
public virtual bool Contains(T aEntry) { CIElement element = CheckValid(aEntry); return(iDictionary.ContainsKey(element.Id)); }
public override void RemoveChild(CIElement aChild) { throw new NotSupportedException("Use Remove() instead"); }
public override void AddChild(CIElement aChild) { throw new NotSupportedException("Use Add() instead"); }