Ejemplo n.º 1
0
        public virtual void Remove(T aEntry)
        {
            CIElement element = CheckValid(aEntry);

            if (iDictionary.ContainsKey(element.Id))
            {
                iDictionary.Remove(element.Id);
            }
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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);
                }
            }
        }
Ejemplo n.º 5
0
 public override bool Contains(CIElement aElement)
 {
     return(this.Contains(aElement.Id));
 }
Ejemplo n.º 6
0
        public virtual bool Contains(T aEntry)
        {
            CIElement element = CheckValid(aEntry);

            return(iDictionary.ContainsKey(element.Id));
        }
Ejemplo n.º 7
0
 public override void RemoveChild(CIElement aChild)
 {
     throw new NotSupportedException("Use Remove() instead");
 }
Ejemplo n.º 8
0
 public override void AddChild(CIElement aChild)
 {
     throw new NotSupportedException("Use Add() instead");
 }