public TreePath(T node, ITreePath <T> parent = null) { if (node == null) { throw new ArgumentNullException(nameof(node)); } Node = node; Parent = parent; }
public ElementEdit( AbstractDocument document, ITreePath <ITextNode> oldElementPath, ITreePath <ITextNode> newElementPath, int index, ITextNode[] addedNodes, ITextNode[] removedNodes) : base(false, "") { Index = index; this.addedNodes = addedNodes; this.removedNodes = removedNodes; this.document = document; this.oldElementPath = oldElementPath; this.newElementPath = newElementPath; }
public static ITreePath <ITextNode> ReplaceAll(ITreePath <ITextNode> oldPath, ITextNode newNode) { var oldNode = oldPath.Node; if (oldPath.Parent == null) { return(new TreePath <ITextNode>(newNode)); } var parentPath = oldPath.Parent; var parentNode = parentPath.Node; var idx = parentNode.IndexOf(oldNode); var changedNode = parentNode.Replace(idx, 1, new[] { newNode }); var changedPath = ReplaceAll(parentPath, changedNode); return(changedPath.Append(newNode)); }
public override ITreeNode Get(ITreePath path, ref int offset, bool getRef = false) { if (path.IsPathToCurrent) { return(this); } if (path.IsAbsolute) { offset = 0; return(Root.Get(path.StepDown(), ref offset, getRef)); } if (path.IsPathIndexed) { var arrayChild = GetChildByName(path.ArrayName); return(arrayChild?.Get(path, ref offset, getRef)); } var child = GetChildByName(path.Nodes.First()); return(child?.Get(path.StepDown(), ref offset, getRef)); }
public override void AddChild(ITreePath path, ITreeNode node) { if (path.IsPathToCurrent) { AddChild(node); } else if (path.IsAbsolute) { Root.AddChild(path.StepDown(), node); } else { var nextNode = path.Nodes.First(); var child = GetChildByName(nextNode); if (child == null) { AddChild(new PlcMetaDataTreeNode(nextNode)); child = GetChildByName(nextNode); } child.AddChild(path.StepDown(), node); } }
public static PlcObject AddPlcObjectToTree(PlcObject obj, ITree tree, ITreePath path) { var node = PlcMetaDataTreePath.CreateNodePath(path, obj); if (!(tree.Get(node) is PlcObject metaDataNode)) { lock (tree.Root) { metaDataNode = tree.Get(node) as PlcObject; if (metaDataNode == null) { tree.Root.AddChild(path, obj); } else { return(metaDataNode); } } return(obj); } return(metaDataNode); }
public override ITreeNode Get(ITreePath path) { int dummy = 0; return(Get(path, ref dummy)); }
public static PlcMetaDataTreePath CreateNodePath(ITreePath path, PlcObject plcObject) => path.Extend(plcObject.Name) as PlcMetaDataTreePath;
public bool TryGet(ITreePath path, ref int offset, out ITreeNode node, bool getRef = false) { node = Root.Get(path, ref offset, getRef); return(node != null); }
public bool TryGet(ITreePath path, out ITreeNode node) { node = Root.Get(path); return(node != null); }
public ITreeNode Get(ITreePath path, ref int offset, bool getRef = false) { return(Root.Get(path, ref offset, getRef)); }
public ITreeNode Get(ITreePath path) { return(Root.Get(path)); }