internal static XmlDiffPathNodeList SelectNodes( XmlDiffViewParentNode rootNode, XmlDiffViewParentNode currentParentNode, string xmlDiffPathExpr) { switch (xmlDiffPathExpr[0]) { case '*': if (xmlDiffPathExpr.Length == 1) { return(XmlDiffPath.SelectAllChildren(currentParentNode)); } XmlDiffPath.OnInvalidExpression(xmlDiffPathExpr); return((XmlDiffPathNodeList)null); case '/': return(XmlDiffPath.SelectAbsoluteNodes(rootNode, xmlDiffPathExpr)); case '@': if (xmlDiffPathExpr.Length < 2) { XmlDiffPath.OnInvalidExpression(xmlDiffPathExpr); } return(xmlDiffPathExpr[1] == '*' ? XmlDiffPath.SelectAllAttributes((XmlDiffViewElement)currentParentNode) : XmlDiffPath.SelectAttributes((XmlDiffViewElement)currentParentNode, xmlDiffPathExpr)); default: return(XmlDiffPath.SelectChildNodes(currentParentNode, xmlDiffPathExpr, 0)); } }
private static XmlDiffPathNodeList SelectAbsoluteNodes( XmlDiffViewParentNode rootNode, string path) { Debug.Assert(path[0] == '/'); var pos = 1; var node = (XmlDiffViewNode)rootNode; int startPos; while (true) { startPos = pos; var num = XmlDiffPath.ReadPosition(path, ref pos); if (pos == path.Length || path[pos] == '/') { if (node.FirstChildNode == null) { XmlDiffPath.OnNoMatchingNode(path); } var diffViewParentNode = (XmlDiffViewParentNode)node; if (num <= 0 || num > diffViewParentNode._sourceChildNodesCount) { XmlDiffPath.OnNoMatchingNode(path); } node = diffViewParentNode.GetSourceChildNode(num - 1); if (pos != path.Length) { ++pos; } else { break; } } else if (path[pos] != '-' && path[pos] != '|') { XmlDiffPath.OnInvalidExpression(path); } else { goto label_10; } } var diffPathNodeList = (XmlDiffPathNodeList) new XmlDiffPathSingleNodeList(); diffPathNodeList.AddNode(node); return(diffPathNodeList); label_10: if (node.FirstChildNode == null) { XmlDiffPath.OnNoMatchingNode(path); } return(XmlDiffPath.SelectChildNodes((XmlDiffViewParentNode)node, path, startPos)); }