System.Xml.XPath.XPathNavigator.IsSamePosition C# (CSharp) Method

IsSamePosition() public abstract method

public abstract IsSamePosition ( XPathNavigator other ) : bool
other XPathNavigator
return bool
        public abstract bool IsSamePosition(XPathNavigator other);

Usage Example

Example #1
0
        /// <include file='doc\XPathNavigator.uex' path='docs/doc[@for="XPathNavigator.ComparePosition"]/*' />
        public virtual XmlNodeOrder ComparePosition(XPathNavigator nav)
        {
            if (IsSamePosition(nav))
            {
                return(XmlNodeOrder.Same);
            }

            XPathNavigator n1 = this.Clone();
            XPathNavigator n2 = nav.Clone();

            int depth1 = GetDepth(n1.Clone());
            int depth2 = GetDepth(n2.Clone());

            if (depth1 > depth2)
            {
                while (depth1 > depth2)
                {
                    n1.MoveToParent();
                    depth1--;
                }
                if (n1.IsSamePosition(n2))
                {
                    return(XmlNodeOrder.After);
                }
            }

            if (depth2 > depth1)
            {
                while (depth2 > depth1)
                {
                    n2.MoveToParent();
                    depth2--;
                }
                if (n1.IsSamePosition(n2))
                {
                    return(XmlNodeOrder.Before);
                }
            }

            XPathNavigator parent1 = n1.Clone();
            XPathNavigator parent2 = n2.Clone();

            while (true)
            {
                if (!parent1.MoveToParent() || !parent2.MoveToParent())
                {
                    return(XmlNodeOrder.Unknown);
                }

                if (parent1.IsSamePosition(parent2))
                {
                    return(CompareSiblings(n1, n2));
                }

                n1.MoveToParent();
                n2.MoveToParent();
            }
        }
All Usage Examples Of System.Xml.XPath.XPathNavigator::IsSamePosition