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 SelectChildNodes(XmlDiffViewParentNode parentNode, string path, int startPos) { int pos = startPos; XmlDiffPathNodeList nodeList = null; //NCOVER DOESN'T LIKE: for (;;) while (true) { int nodePos = ReadPosition(path, ref pos); if (pos == path.Length) { nodeList = new XmlDiffPathSingleNodeList(); } else { nodeList = new XmlDiffPathMultiNodeList(); } if (nodePos <= 0 || nodePos > parentNode._sourceChildNodesCount) { OnNoMatchingNode(path); } nodeList.AddNode(parentNode.GetSourceChildNode(nodePos - 1)); if (pos == path.Length) { break; } else if (path[pos] == '|') { pos++; } else if (path[pos] == '-') { pos++; int endNodePos = ReadPosition(path, ref pos); if (endNodePos <= 0 || endNodePos > parentNode._sourceChildNodesCount) { OnNoMatchingNode(path); } while (nodePos < endNodePos) { nodePos++; nodeList.AddNode(parentNode.GetSourceChildNode(nodePos - 1)); } if (pos == path.Length) { break; } else if (path[pos] == '|') { pos++; } else { OnInvalidExpression(path); } } } return(nodeList); }