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); }
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) where T : CIElement { return(ChildrenByType <T>(aType, null)); }