static XmlDiffPathNodeList SelectAllChildren(XmlDiffViewParentNode parentNode) { if (parentNode._childNodes == null) { OnNoMatchingNode("*"); return(null); } else if (parentNode._childNodes._nextSibbling == null) { XmlDiffPathNodeList nodeList = new XmlDiffPathSingleNodeList(); nodeList.AddNode(parentNode._childNodes); return(nodeList); } else { XmlDiffPathNodeList nodeList = new XmlDiffPathMultiNodeList(); XmlDiffViewNode childNode = parentNode._childNodes; while (childNode != null) { nodeList.AddNode(childNode); childNode = childNode._nextSibbling; } return(nodeList); } }
static XmlDiffPathNodeList SelectAbsoluteNodes(XmlDiffViewParentNode rootNode, string path) { Debug.Assert(path[0] == '/'); int pos = 1; XmlDiffViewNode node = rootNode; //why??this line screws up ncover: for (;;) while (true) { int startPos = pos; int nodePos = ReadPosition(path, ref pos); if (pos == path.Length || path[pos] == '/') { if (node.FirstChildNode == null) { OnNoMatchingNode(path); } XmlDiffViewParentNode parentNode = (XmlDiffViewParentNode)node; if (nodePos <= 0 || nodePos > parentNode._sourceChildNodesCount) { OnNoMatchingNode(path); } node = parentNode.GetSourceChildNode(nodePos - 1); if (pos == path.Length) { XmlDiffPathNodeList list = new XmlDiffPathSingleNodeList(); list.AddNode(node); return(list); } pos++; } else { if (path[pos] == '-' || path[pos] == '|') { if (node.FirstChildNode == null) { OnNoMatchingNode(path); } return(SelectChildNodes(((XmlDiffViewParentNode)node), path, startPos)); } OnInvalidExpression(path); } } throw new InvalidOperationException(); // This is necessary for NCover. Otherwise NCover screws up the output when instrumenting. }
static XmlDiffPathNodeList SelectAllAttributes(XmlDiffViewElement parentElement) { if (parentElement._attributes == null) { OnNoMatchingNode("@*"); return(null); } else if (parentElement._attributes._nextSibbling == null) { XmlDiffPathNodeList nodeList = new XmlDiffPathSingleNodeList(); nodeList.AddNode(parentElement._attributes); return(nodeList); } else { XmlDiffPathNodeList nodeList = new XmlDiffPathMultiNodeList(); XmlDiffViewAttribute curAttr = parentElement._attributes; while (curAttr != null) { nodeList.AddNode(curAttr); } return(nodeList); } }