System.Xml.Xsl.Runtime.XsltLibrary.IsSameNodeSort C# (CSharp) Method

IsSameNodeSort() public method

public IsSameNodeSort ( XPathNavigator nav1, XPathNavigator nav2 ) : bool
nav1 System.Xml.XPath.XPathNavigator
nav2 System.Xml.XPath.XPathNavigator
return bool
        public bool IsSameNodeSort(XPathNavigator nav1, XPathNavigator nav2)
        {
            Debug.Assert(XPathNodeType.SignificantWhitespace == XPathNodeType.Text + 1);
            Debug.Assert(XPathNodeType.Whitespace == XPathNodeType.Text + 2);

            XPathNodeType nt1 = nav1.NodeType;
            XPathNodeType nt2 = nav2.NodeType;

            // If one of nodes is a text node, the other one must also be a text node
            if (XPathNodeType.Text <= nt1 && nt1 <= XPathNodeType.Whitespace)
            {
                return XPathNodeType.Text <= nt2 && nt2 <= XPathNodeType.Whitespace;
            }

            // Otherwise nodes must have the same node kind, the same local name, and the same namespace URI
            Debug.Assert((object)nav1.NameTable == (object)nav2.NameTable, "Ref.Equal cannot be used if navigators have different name tables");
            return nt1 == nt2 && Ref.Equal(nav1.LocalName, nav2.LocalName) && Ref.Equal(nav1.NamespaceURI, nav2.NamespaceURI);
        }