예제 #1
0
        public void AddNode(string path)
        {
            string[] nodeNames = path.Split(new char[] { NameSeperator });
            ItemTree br        = this;                     // root

            for (int i = 0; i < nodeNames.Length - 1; ++i) // branches
            {
                ItemTree ch = br.FindChild(nodeNames[i]);
                if (ch == null) // not found
                {
                    ch          = new ItemTree(NameSeperator);
                    ch.nodeName = nodeNames[i];
                    if (br.pathName == "")
                    {
                        ch.pathName = nodeNames[i];
                    }
                    else
                    {
                        ch.pathName = br.pathName + NameSeperator + nodeNames[i];
                    }
                    ch.parent = br;
                    br.childs.Add(ch);
                }
                br = ch; // child as current branch
            }
            ItemTree ich = new ItemTree(NameSeperator);

            ich.nodeName = nodeNames[nodeNames.Length - 1];
            ich.pathName = path;
            ich.parent   = br;
            ich.isItem   = true;
            br.childs.Add(ich);
        }
예제 #2
0
        public ItemTree FindNode(string path)
        {
            string[] nodeNames = path.Split(new char[] { NameSeperator });
            ItemTree br        = this;                 // root

            for (int i = 0; i < nodeNames.Length; ++i) // nodes
            {
                ItemTree ch = br.FindChild(nodeNames[i]);
                if (ch == null) // not found
                {
                    return(null);
                }
                br = ch; // child as current branch
            }
            return(br);
        }
예제 #3
0
 //---------------------------------------- constructor
 public ConfigData(int numItems, char sep)
 {
     Items         = new ItemData[numItems];
     NameSeperator = sep;
     Branches      = new ItemTree(sep);
 }