public void CheckCreate3() { AttributeTree at = new AttributeTree(); AttributeTree at2 = at.Children["/missing/inner/node", true]; Assert.IsTrue(at2 != null); Assert.IsTrue(at.Children["/missing/inner", false] != null); }
public void CheckCreate4() { AttributeTree at = new AttributeTree(); AttributeTree at2 = at.Children["/found/inner", true]; at2.Create("/node"); Assert.IsTrue(at.Children["/found/inner/node", false] != null); }
public void CheckNullSub() { // Create an empty one AttributeTree at = new AttributeTree(); Assert.IsTrue(at.Children["/missing/inner/node"] == null); }
public void CheckNull2() { // Create an empty one AttributeTree at = new AttributeTree(); Assert.IsTrue(at.Children["/missing", false] == null); }
public void CheckCreate2() { AttributeTree at = new AttributeTree(); Assert.IsTrue(at.Children["/missing", true] != null); }
public void AddingPluses() { AttributeTree at = new AttributeTree(); AttributeTree at2 = at["/Test/Test +1", true]; Assert.AreEqual("Test +1", at2.Path.Name); }
public AttributeTreeCollection(AttributeTree baseTree) { this.baseTree = baseTree; }
/// <summary> /// Called when a new child is created (but not cloned). /// </summary> public virtual void OnCreatedAsChild(NodeRef nref, AttributeTree parent) { Path = new NodeRef(parent.Path.ToString() + nref.ToString()); }
/// <summary> /// Merges this attribute tree with the given attribute /// tree. Merging is done by copying all of the attributes from /// the given tree into the current one. Then, for every child in /// both trees, they are copied in. Nodes that are not the destination /// tree are just copied (deep copy) while those in the tree are /// merged as per this method, recursively. /// </summary> public void Merge(AttributeTree source) { // Copy the attributes foreach (string key in source.attributes.Keys) attributes[key] = source.attributes[key]; // Copy the children foreach (string name in source.children.Keys) { // Get the attribute tree AttributeTree at = (AttributeTree) source.children[name]; if (at == null) { throw new UtilityException("Cannot retrieve object from " + name); } // Check to see if this is already here if (children[name] != null) { // We have to merge AttributeTree dat = (AttributeTree) children[name]; dat.Merge(at); } else { AttributeTree cloned = (AttributeTree) at.Clone(); children.Add(name, cloned); } } }