示例#1
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));
        }
示例#2
0
        private static XmlDiffPathNodeList SelectAttributes(
            XmlDiffViewElement parentElement,
            string path)
        {
            Debug.Assert(path[0] == '@');
            var pos = 1;
            var diffPathNodeList = (XmlDiffPathNodeList)null;

            while (true)
            {
                var name = XmlDiffPath.ReadAttrName(path, ref pos);
                if (diffPathNodeList == null)
                {
                    diffPathNodeList = pos != path.Length ? (XmlDiffPathNodeList) new XmlDiffPathMultiNodeList() : (XmlDiffPathNodeList) new XmlDiffPathSingleNodeList();
                }
                var attribute = parentElement.GetAttribute(name);
                if (attribute == null)
                {
                    XmlDiffPath.OnNoMatchingNode(path);
                }
                diffPathNodeList.AddNode((XmlDiffViewNode)attribute);
                if (pos != path.Length)
                {
                    if (path[pos] == '|')
                    {
                        var index = pos + 1;
                        if (path[index] != '@')
                        {
                            XmlDiffPath.OnInvalidExpression(path);
                        }
                        pos = index + 1;
                    }
                    else
                    {
                        XmlDiffPath.OnInvalidExpression(path);
                    }
                }
                else
                {
                    break;
                }
            }
            return(diffPathNodeList);
        }
示例#3
0
        private static XmlDiffPathNodeList SelectAllChildren(
            XmlDiffViewParentNode parentNode)
        {
            if (parentNode._childNodes == null)
            {
                XmlDiffPath.OnNoMatchingNode("*");
                return((XmlDiffPathNodeList)null);
            }
            if (parentNode._childNodes._nextSibbling == null)
            {
                var diffPathNodeList = (XmlDiffPathNodeList) new XmlDiffPathSingleNodeList();
                diffPathNodeList.AddNode(parentNode._childNodes);
                return(diffPathNodeList);
            }
            var diffPathNodeList1 = (XmlDiffPathNodeList) new XmlDiffPathMultiNodeList();

            for (var node = parentNode._childNodes; node != null; node = node._nextSibbling)
            {
                diffPathNodeList1.AddNode(node);
            }
            return(diffPathNodeList1);
        }
示例#4
0
        private static XmlDiffPathNodeList SelectAllAttributes(
            XmlDiffViewElement parentElement)
        {
            if (parentElement._attributes == null)
            {
                XmlDiffPath.OnNoMatchingNode("@*");
                return((XmlDiffPathNodeList)null);
            }
            if (parentElement._attributes._nextSibbling == null)
            {
                var diffPathNodeList = (XmlDiffPathNodeList) new XmlDiffPathSingleNodeList();
                diffPathNodeList.AddNode((XmlDiffViewNode)parentElement._attributes);
                return(diffPathNodeList);
            }
            var diffPathNodeList1 = (XmlDiffPathNodeList) new XmlDiffPathMultiNodeList();
            var attributes        = parentElement._attributes;

            while (attributes != null)
            {
                diffPathNodeList1.AddNode((XmlDiffViewNode)attributes);
            }
            return(diffPathNodeList1);
        }
示例#5
0
        private static XmlDiffPathNodeList SelectChildNodes(
            XmlDiffViewParentNode parentNode,
            string path,
            int startPos)
        {
            var pos = startPos;
            XmlDiffPathNodeList diffPathNodeList;

            while (true)
            {
                int num1;
                do
                {
                    num1             = XmlDiffPath.ReadPosition(path, ref pos);
                    diffPathNodeList = pos != path.Length ? (XmlDiffPathNodeList) new XmlDiffPathMultiNodeList() : (XmlDiffPathNodeList) new XmlDiffPathSingleNodeList();
                    if (num1 <= 0 || num1 > parentNode._sourceChildNodesCount)
                    {
                        XmlDiffPath.OnNoMatchingNode(path);
                    }
                    diffPathNodeList.AddNode(parentNode.GetSourceChildNode(num1 - 1));
                    if (pos != path.Length)
                    {
                        if (path[pos] == '|')
                        {
                            ++pos;
                        }
                    }
                    else
                    {
                        goto label_15;
                    }
                }while (path[pos] != '-');
                ++pos;
                var num2 = XmlDiffPath.ReadPosition(path, ref pos);
                if (num2 <= 0 || num2 > parentNode._sourceChildNodesCount)
                {
                    XmlDiffPath.OnNoMatchingNode(path);
                }
                while (num1 < num2)
                {
                    ++num1;
                    diffPathNodeList.AddNode(parentNode.GetSourceChildNode(num1 - 1));
                }
                if (pos != path.Length)
                {
                    if (path[pos] == '|')
                    {
                        ++pos;
                    }
                    else
                    {
                        XmlDiffPath.OnInvalidExpression(path);
                    }
                }
                else
                {
                    break;
                }
            }
label_15:
            return(diffPathNodeList);
        }