Beispiel #1
0
        /// <summary>
        /// 无论如何都添加
        /// </summary>
        /// <param name="child"></param>
        public void ChildAdd(NameInfo child)
        {
            Cataory t = new Cataory(child);

            t.parent = this;
            parent.childs.Add(t);
        }
Beispiel #2
0
        /// <summary>
        /// 子元素索引
        /// </summary>
        /// <param name="child"></param>
        /// <returns></returns>
        public int ChildIndexOf(NameInfo child)
        {
            Cataory old = childs.FirstOrDefault <Cataory>(x => x.Data.Equals(child));

            if (old == null)
            {
                return(-1);
            }
            return(childs.IndexOf(old));
        }
Beispiel #3
0
        /// <summary>
        /// 如果child已经不存在,则添加
        /// </summary>
        /// <param name="child"></param>
        public void ChildPut(NameInfo child)
        {
            Cataory old = childs.FirstOrDefault <Cataory>(x => x.Data.Equals(child));

            if (old == null)
            {
                old        = new Cataory(child);
                old.parent = this;
                parent.childs.Add(old);
                return;
            }
            old.parent = this;
        }
Beispiel #4
0
 public static Cataory FindChild(Cataory parent, String name)
 {
     if (parent == null)
     {
         return(null);
     }
     foreach (Cataory e in parent.childs)
     {
         if (e.Data.hasName(name))
         {
             return(e);
         }
         Cataory t = FindChild(e, name);
         if (t != null)
         {
             return(t);
         }
     }
     return(null);
 }