public static void Merge(this UxNode dst, UxNode src) { if (dst == null) { throw new ArgumentNullException(nameof(dst)); } if (src == null) { throw new ArgumentNullException(nameof(src)); } if (dst.NodeType != src.NodeType) { throw new InvalidOperationException("Node type of merge source must be same as destination."); } switch (src.NodeType) { case XmlNodeType.Element: MergeElement((UxElement)dst, (UxElement)src); break; case XmlNodeType.Comment: case XmlNodeType.Text: case XmlNodeType.CDATA: dst.ReplaceSyntax(src.Syntax); break; //case XmlNodeType.Document: // Merge(((XDocument)dst).Root, ((XDocument)src).Root); // break; default: throw new NotImplementedException("Don't know how to merge "); } }
public static UxNodePath From(UxNode node) { var depth = node.Depth; var indexes = new int[depth + 1]; for (var i = depth; i >= 0; i--) { indexes[i] = node.NodeIndex; node = node.Parent; } return(new UxNodePath(indexes)); }
protected override bool OnTryApply(UxDocument document) { if (!NodePath.TryFind(document, out UxNode node)) { return(false); } if (!node.Syntax.Equals(OldNode)) { return(false); } node.ReplaceWith(UxNode.FromSyntax(NewNode)); return(true); }
protected override bool OnTryApply(UxDocument document) { IUxContainer parent; if (!NodePath.TryFindPathParent(document, out parent)) { return(false); } var index = NodePath.Indexes.LastOrDefault(); if (index > parent.Nodes.Count) { return(false); } parent.Nodes.Insert(index, UxNode.FromSyntax(Node)); return(true); }
public static bool DeepEquals(this UxNode a, UxNode b) { return(a.Syntax.Equals(b.Syntax)); }
static UxNode CloneNode(UxNode srcNode) { return(srcNode.DetachedNodeClone()); }