System.Xml.Xsl.Runtime.XmlQueryRuntime.ComparePosition C# (CSharp) Method

ComparePosition() public method

Compare the relative positions of two navigators. Return -1 if navThis is before navThat, 1 if after, and 0 if they are positioned to the same node.
public ComparePosition ( XPathNavigator navigatorThis, XPathNavigator navigatorThat ) : int
navigatorThis System.Xml.XPath.XPathNavigator
navigatorThat System.Xml.XPath.XPathNavigator
return int
        public int ComparePosition(XPathNavigator navigatorThis, XPathNavigator navigatorThat) {
            return this.docOrderCmp.Compare(navigatorThis, navigatorThat);
        }

Usage Example

Exemplo n.º 1
0
        /// <summary>
        /// Insert the specified sequence into the list of sequences to be merged.
        /// Insert it in reverse document order with respect to the current nodes in other sequences.
        /// </summary>
        private void InsertSequence(IEnumerator <XPathNavigator> sequence)
        {
            for (int i = _sequencesToMerge.Count - 1; i >= 0; i--)
            {
                int cmp = _runtime.ComparePosition(sequence.Current, _sequencesToMerge[i].Current);

                if (cmp == -1)
                {
                    // Insert after current item
                    _sequencesToMerge.Insert(i + 1, sequence);
                    return;
                }
                else if (cmp == 0)
                {
                    // Found duplicate, so skip the duplicate
                    if (!sequence.MoveNext())
                    {
                        // No more nodes, so don't insert anything
                        return;
                    }

                    // Next node must be after current node in document order, so don't need to reset loop
                }
            }

            // Insert at beginning of list
            _sequencesToMerge.Insert(0, sequence);
        }
All Usage Examples Of System.Xml.Xsl.Runtime.XmlQueryRuntime::ComparePosition