コード例 #1
0
        public void IncrementNode(string treePath, int count)
        {
            // HACK: 10 is a magic number.  I just don't think
            // my resource trees will ever be 10 deep
            string[] pathstr = treePath.Split(new char[] { ' ' }, 10);
            AppNode  curNode = top;

            for (int i = 0; i < pathstr.Length; i++)
            {
                if (pathstr[i].Equals(""))
                {
                    continue;
                }
                // find the child that has the right name
                bool found = false;
                for (int j = 0; j < curNode.NumChildren; j++)
                {
                    if (curNode[j].Name == pathstr[i])
                    {
                        curNode = curNode[j];
                        found   = true;
                        break;
                    }
                }
                Debug.Assert(found);
            }
            curNode.Increment(count);
            return;
        }
コード例 #2
0
ファイル: AppNode.cs プロジェクト: Paul1nh0/Singularity
 public AppNode(string nodeName, AppNode parent)
 {
     this.nodeName = nodeName;
     this.parent   = parent;
     if (parent != null)
     {
         parent.AddChild(this);
     }
     count         = 0;
     this.children = new ArrayList();
     normalized    = false;
 }
コード例 #3
0
ファイル: AppNode.cs プロジェクト: Paul1nh0/Singularity
        public AppNode Copy(AppNode inParent)
        {
            AppNode outnode = new AppNode(this.nodeName, inParent);

            outnode.count      = this.count;
            outnode.normalized = this.normalized;
            for (int i = 0; i < this.children.Count; i++)
            {
                // this looks like a throwaway, but in the constructor it will attach to us
                ((AppNode)this.children[i]).Copy(outnode);
            }
            return(outnode);
        }
コード例 #4
0
        public static AppTree CreateAppTree(string filename)
        {
            // parse the app tree structure here
            StreamReader ios = new StreamReader(filename);
            string       curLine;
            // this is the first node we create
            AppNode top          = null;
            AppNode lastNode     = null;
            int     lastTabCount = 0;

            while ((curLine = ios.ReadLine()) != null)
            {
                int tabcount = curLine.LastIndexOf("\t");
                tabcount++;
                //Console.WriteLine("Got tabcount {0}", tabcount);
                Debug.Assert(tabcount >= 0);

                string  name   = curLine.Substring(tabcount);
                AppNode parent = lastNode == null ? null : lastNode.Parent;
                if (tabcount < lastTabCount)
                {
                    // then walk up the tree to the new parent
                    int diff = lastTabCount - tabcount;
                    while (diff-- > 0)
                    {
                        parent = parent.Parent;
                        Debug.Assert(parent != null);
                    }
                }
                else if (tabcount > lastTabCount)
                {
                    parent = lastNode;
                    Debug.Assert(tabcount == lastTabCount + 1);
                }
                // this automatically joins this node to its parent in the tree
                AppNode tempNode = new AppNode(name, parent);
                if (top == null)
                {
                    Debug.Assert(tabcount == 0);
                    top = tempNode;
                }
                lastNode     = tempNode;
                lastTabCount = tabcount;
            }
            AppTree outtree = new AppTree(top);

            return(outtree);
        }
コード例 #5
0
 public AppTree(AppTree other)
 {
     // we just walk the other tree and get a new copy
     this.top = other.top.Copy(null);
 }
コード例 #6
0
 public AppTree(AppNode top)
 {
     this.top = top;
 }
コード例 #7
0
ファイル: AppNode.cs プロジェクト: Paul1nh0/Singularity
 public void AddChild(AppNode child)
 {
     children.Add(child);
     return;
 }