Пример #1
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);
            }
        }
Пример #2
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);
                }
            }
        }