Beispiel #1
0
        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);
                }
            }
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        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);
            }
        }
Beispiel #4
0
 System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
 {
     lock ( iSyncLock )
     {
         CIElementList <CIElement> children = iChildren;
         if (iChildren == null)
         {
             children = new CIElementList <CIElement>(Container);
         }
         return(children.GetEnumerator());
     }
 }
Beispiel #5
0
 public IEnumerator <CIElement> GetEnumerator()
 {
     lock ( iSyncLock )
     {
         CIElementList <CIElement> children = iChildren;
         if (iChildren == null)
         {
             children = new CIElementList <CIElement>(Container);
         }
         return(children.GetEnumerator());
     }
 }
Beispiel #6
0
        public CIElementList <T> ChildrenByType <T>(Predicate <T> aPredicate) where T : CIElement
        {
            CIElementList <T> ret = ChildrenByType <T>(TChildSearchType.EDirectChildrenOnly, aPredicate);

            return(ret);
        }
Beispiel #7
0
        public CIElementList <T> ChildrenByType <T>() where T : CIElement
        {
            CIElementList <T> ret = ChildrenByType <T>(TChildSearchType.EDirectChildrenOnly);

            return(ret);
        }