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); } }
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); } } }