Ejemplo n.º 1
0
        public virtual void ResolveParentLink(IDocNode parent, string name)
        {
            if (parent != Parent && !(Parent == null || parent == null))
            {
                throw new Exception("Can not have two parents!");
            }

            Parent = parent;
            Name   = name;
        }
Ejemplo n.º 2
0
        public static T ChildByPath <T>(IDocNode root, string path) where T : IDocLeaf
        {
            string[] names = SplitPath(path);

            IDocLeaf cur = root;

            foreach (string name in names)
            {
                cur = (cur as IDocNode).ChildByName(name);
            }

            return((T)cur);
        }
Ejemplo n.º 3
0
        public static void CollectChildrenRecursive(IDocLeaf root, List <IDocLeaf> collection)
        {
            collection.Add(root);

            if (root is IDocNode)
            {
                IDocNode node = (IDocNode)root;

                IEnumerable <IDocLeaf> children = node.Children();
                foreach (IDocLeaf child in children)
                {
                    CollectChildrenRecursive(child, collection);
                }
            }
        }
Ejemplo n.º 4
0
        static void TestDocNodeResolveChildrenLinks()
        {
            IDocNode t0 = DocNode.Create <TestDocNodeClassBase>();

            UnitTest.Test(t0.Children().Count() == 2);
            foreach (IDocLeaf doc in t0.Children())
            {
                UnitTest.Test(doc.Parent == t0);
            }

            IDocNode t1 = DocNode.Create <TestDocNodeClassDerived>();

            UnitTest.Test(t1.Children().Count() == 4);
            foreach (IDocLeaf doc in t1.Children())
            {
                UnitTest.Test(doc.Parent == t1);
            }
        }
Ejemplo n.º 5
0
        static void TestDocNodeChildrenNames()
        {
            IDocNode t0 = DocNode.Create <TestDocNodeClassBase>();

            IList <string> childrenNames0 = t0.ChildrenNames() as IList <string>;

            UnitTest.Test(childrenNames0.Count == 2);
            UnitTest.Test(childrenNames0[0] == "M0");
            UnitTest.Test(childrenNames0[1] == "M1");

            IDocNode t1 = DocNode.Create <TestDocNodeClassDerived>();

            IList <string> childrenNames1 = t1.ChildrenNames() as IList <string>;

            UnitTest.Test(childrenNames1.Count == 4);
            UnitTest.Test(childrenNames1[0] == "M2");
            UnitTest.Test(childrenNames1[1] == "M3");
            UnitTest.Test(childrenNames1[2] == "M0");
            UnitTest.Test(childrenNames1[3] == "M1");
        }
Ejemplo n.º 6
0
 public void ResolveParentLink(IDocNode parent, string name)
 {
     Parent = parent;
     Name   = name;
 }
Ejemplo n.º 7
0
 public override void ResolveParentLink(IDocNode parent, string name)
 {
     base.ResolveParentLink(parent, name);
     IsTemplateItem.Value = CalculateIsTemplateItem;
 }