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 SelectAttributes(XmlDiffViewElement parentElement, string path)
        {
            Debug.Assert(path[0] == '@');

            int pos = 1;
            XmlDiffPathNodeList nodeList = null;

            //NCOVER DOESN'T LIKE: for (;;)
            while (true)
            {
                string name = ReadAttrName(path, ref pos);

                if (nodeList == null)
                {
                    if (pos == path.Length)
                    {
                        nodeList = new XmlDiffPathSingleNodeList();
                    }
                    else
                    {
                        nodeList = new XmlDiffPathMultiNodeList();
                    }
                }

                XmlDiffViewAttribute attr = parentElement.GetAttribute(name);
                if (attr == null)
                {
                    OnNoMatchingNode(path);
                }

                nodeList.AddNode(attr);

                if (pos == path.Length)
                {
                    break;
                }
                else if (path[pos] == '|')
                {
                    pos++;
                    if (path[pos] != '@')
                    {
                        OnInvalidExpression(path);
                    }
                    pos++;
                }
                else
                {
                    OnInvalidExpression(path);
                }
            }

            return(nodeList);
        }
 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);
     }
 }
        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);
        }