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; }
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); }
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); } } }
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); } }
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"); }
public void ResolveParentLink(IDocNode parent, string name) { Parent = parent; Name = name; }
public override void ResolveParentLink(IDocNode parent, string name) { base.ResolveParentLink(parent, name); IsTemplateItem.Value = CalculateIsTemplateItem; }