internal virtual void GetChildrenByType <T>(CIElementList <T> aList, TChildSearchType aType, Predicate <T> aPredicate) where T : CIElement { // Get all direct children, and if recusion enabled, then fetch the // entire tree. Type t = typeof(T); foreach (CIElement element in Children) { if (t.IsAssignableFrom(element.GetType())) { // Get entry of correct type T objectEntry = (T)((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 <T>(aList, aType, aPredicate); } } }
public CIElementList <T> ChildrenByType <T>(TChildSearchType aType, Predicate <T> aPredicate) where T : CIElement { CIElementList <T> ret = new CIElementList <T>(Container); GetChildrenByType <T>(ret, aType, aPredicate); return(ret); }
public virtual void AddChild(CIElement aChild) { if (aChild != null) { // If we have been restricted to a specific // type of child element, then check aChild against // it... Type t = aChild.GetType(); ValidateChildType(t); lock ( iSyncLock ) { if (iChildren == null) { iChildren = new CIElementList <CIElement>(Container); iChildren.IsInContainer = this.IsInContainer; } if (aChild.Parent == null) { aChild.Parent = this; } iChildren.Add(aChild); } OnElementAddedToSelf(aChild); } }
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { lock ( iSyncLock ) { CIElementList <CIElement> children = iChildren; if (iChildren == null) { children = new CIElementList <CIElement>(Container); } return(children.GetEnumerator()); } }
public IEnumerator <CIElement> GetEnumerator() { lock ( iSyncLock ) { CIElementList <CIElement> children = iChildren; if (iChildren == null) { children = new CIElementList <CIElement>(Container); } return(children.GetEnumerator()); } }
public CIElementList <T> ChildrenByType <T>(Predicate <T> aPredicate) where T : CIElement { CIElementList <T> ret = ChildrenByType <T>(TChildSearchType.EDirectChildrenOnly, aPredicate); return(ret); }
public CIElementList <T> ChildrenByType <T>() where T : CIElement { CIElementList <T> ret = ChildrenByType <T>(TChildSearchType.EDirectChildrenOnly); return(ret); }