Esempio n. 1
0
        public CatMetaDataBlock(AstMetaDataBlock node)
            : base("root", null)
        {
            CatMetaData cur        = this;
            int         nCurIndent = -1;

            for (int i = 0; i < node.children.Count; ++i)
            {
                AstMetaData tmp = node.children[i];
                if (tmp is AstMetaDataLabel)
                {
                    int    nIndent;
                    string sName;
                    SplitLabel(tmp.ToString(), out nIndent, out sName);

                    if (nIndent > nCurIndent)
                    {
                        cur = cur.NewChild(sName);
                    }
                    else if (nIndent == nCurIndent)
                    {
                        cur = cur.GetParent();
                        Trace.Assert(cur != null);
                        cur = cur.NewChild(sName);
                    }
                    else
                    {
                        cur = cur.GetParent();
                        Trace.Assert(cur != null);
                        cur = cur.GetParent();
                        Trace.Assert(cur != null);
                        cur = cur.NewChild(sName);
                    }
                    nCurIndent = nIndent;
                }
                else if (tmp is AstMetaDataContent)
                {
                    cur.AddContent(tmp.ToString());
                }
                else
                {
                    throw new Exception("invalid AstMetaDataBlock");
                }
            }
        }