Ejemplo n.º 1
0
        /// <summary>
        /// childPath形如:Lcom/ltsdk_167_xiaomihaiwai/v1_0_5/R$string;
        /// </summary>
        /// <param name="childPath"></param>
        private void AddChildByPath(String childPath)
        {
            // 获取所有子节点名称信息
            String[] A = childPath.Split('/');

            // 逐级添加子节点
            ClassTree tree = this;

            for (int i = 0; i < A.Length; i++)
            {
                string name = A[i];
                if (i == A.Length - 1)
                {
                    name += ".class";
                }

                tree.AddChild(name);
                tree = tree.childs[name];

                if (i == A.Length - 1)
                {
                    tree.isDir = false;                     // 最后一个设置为
                }
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 添加tree至当前节点的子节点中
 /// </summary>
 /// <param name="tree"></param>
 public void AddChild(ClassTree tree)
 {
     // 若子节点中不含有该节点,则直接添加
     if (!childs.ContainsKey(tree.Name))
     {
         childs.Add(tree.Name, tree);
         tree.parent = this;
     }
     // 若子节点中已含有该节点,则合并至同名子节点
     else
     {
         ClassTree child = childs[tree.Name];                // 获取子节点
         foreach (ClassTree sChild in tree.childs.Values)    // 添加tree的所有子节点
         {
             child.AddChild(sChild);
         }
     }
 }