Exemplo n.º 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);
        }
Exemplo n.º 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));
        }
Exemplo n.º 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;
        }
Exemplo n.º 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);
 }