Advance() public abstract method

public abstract Advance ( ) : XPathNavigator
return System.Xml.XPath.XPathNavigator
        private double Number(XPathNodeIterator nodeIterator)
        {
            if (arg == null)
            {
                return(XmlConvertEx.ToXPathDouble(nodeIterator.Current.Value));
            }
            object argVal = arg.Evaluate(nodeIterator);

            switch (GetXPathType(argVal))
            {
            case XPathResultType.NodeSet:
                XPathNavigator value = arg.Advance();
                if (value != null)
                {
                    return(Number(value.Value));
                }
                break;

            case XPathResultType.String:
                return(Number((string)argVal));

            case XPathResultType.Boolean:
                return(Number((bool)argVal));

            case XPathResultType.Number:
                return((double)argVal);

            case XPathResultType_Navigator:
                return(Number(((XPathNavigator)argVal).Value));
            }
            return(double.NaN);
        }
Beispiel #2
0
 private XPathNavigator EvaluateArg(XPathNodeIterator context)
 {
     if (_arg == null)
     {
         return(context.Current);
     }
     _arg.Evaluate(context);
     return(_arg.Advance());
 }
Beispiel #3
0
        internal bool toBoolean(XPathNodeIterator nodeIterator)
        {
            object result = _arg.Evaluate(nodeIterator);

            if (result is XPathNodeIterator)
            {
                return(_arg.Advance() != null);
            }

            string str = result as string;

            if (str != null)
            {
                return(toBoolean(str));
            }

            if (result is double)
            {
                return(toBoolean((double)result));
            }
            if (result is bool)
            {
                return((bool)result);
            }
            Debug.Assert(result is XPathNavigator, "Unknown value type");
            return(true);
        }
 public static void AssertQuery(Query query)
 {
     if (!(query is FunctionQuery))
     {
         XPathNavigator navigator2;
         query = Clone(query);
         XPathNavigator l     = null;
         int            count = query.Clone().Count;
         for (int i = 0; (navigator2 = query.Advance()) != null; i++)
         {
             if (navigator2.GetType().ToString() == "Microsoft.VisualStudio.Modeling.StoreNavigator")
             {
                 return;
             }
             if (navigator2.GetType().ToString() == "System.Xml.DataDocumentXPathNavigator")
             {
                 return;
             }
             if ((l != null) && ((l.NodeType != XPathNodeType.Namespace) || (navigator2.NodeType != XPathNodeType.Namespace)))
             {
                 CompareNodes(l, navigator2);
             }
             l = navigator2.Clone();
         }
     }
 }
 public static void AssertQuery(Query query)
 {
     if (!(query is FunctionQuery))
     {
         XPathNavigator navigator2;
         query = Clone(query);
         XPathNavigator l = null;
         int count = query.Clone().Count;
         for (int i = 0; (navigator2 = query.Advance()) != null; i++)
         {
             if (navigator2.GetType().ToString() == "Microsoft.VisualStudio.Modeling.StoreNavigator")
             {
                 return;
             }
             if (navigator2.GetType().ToString() == "System.Xml.DataDocumentXPathNavigator")
             {
                 return;
             }
             if ((l != null) && ((l.NodeType != XPathNodeType.Namespace) || (navigator2.NodeType != XPathNodeType.Namespace)))
             {
                 CompareNodes(l, navigator2);
             }
             l = navigator2.Clone();
         }
     }
 }
Beispiel #6
0
        public override XPathNavigator Advance()
        {
            XPathNavigator res1, res2;
            XmlNodeOrder   order = 0;

            if (_advance1)
            {
                res1 = qy1.Advance();
            }
            else
            {
                res1 = _nextNode;
            }
            if (_advance2)
            {
                res2 = qy2.Advance();
            }
            else
            {
                res2 = _nextNode;
            }
            if (res1 != null && res2 != null)
            {
                order = CompareNodes(res1, res2);
            }
            else if (res2 == null)
            {
                _advance1    = true;
                _advance2    = false;
                _currentNode = res1;
                _nextNode    = null;
                return(res1);
            }
            else
            {
                _advance1    = false;
                _advance2    = true;
                _currentNode = res2;
                _nextNode    = null;
                return(res2);
            }

            if (order == XmlNodeOrder.Before)
            {
                return(ProcessBeforePosition(res1, res2));
            }
            else if (order == XmlNodeOrder.After)
            {
                return(ProcessAfterPosition(res1, res2));
            }
            else
            {
                // BugBug. In case of Unknown we sorting as the same.
                return(ProcessSamePosition(res1));
            }
        }
        public override XPathNavigator Advance()
        {
            XPathNavigator res1, res2;
            XmlNodeOrder   order = 0;

            if (advance1)
            {
                res1 = qy1.Advance();
            }
            else
            {
                res1 = nextNode;
            }
            if (advance2)
            {
                res2 = qy2.Advance();
            }
            else
            {
                res2 = nextNode;
            }
            if (res1 != null && res2 != null)
            {
                order = CompareNodes(res1, res2);
            }
            else if (res2 == null)
            {
                advance1    = true;
                advance2    = false;
                currentNode = res1;
                nextNode    = null;
                return(res1);
            }
            else
            {
                advance1    = false;
                advance2    = true;
                currentNode = res2;
                nextNode    = null;
                return(res2);
            }

            if (order == XmlNodeOrder.Before)
            {
                return(ProcessBeforePosition(res1, res2));
            }
            else if (order == XmlNodeOrder.After)
            {
                return(ProcessAfterPosition(res1, res2));
            }
            else
            {
                return(ProcessSamePosition(res1));
            }
        }
Beispiel #8
0
        internal bool EvaluatePredicate()
        {
            object value = _cond.Evaluate(qyInput);

            if (value is XPathNodeIterator)
            {
                return(_cond.Advance() != null);
            }
            if (value is string)
            {
                return(((string)value).Length != 0);
            }
            if (value is double)
            {
                return(((double)value) == qyInput.CurrentPosition);
            }
            if (value is bool)
            {
                return((bool)value);
            }
            Debug.Assert(value is XPathNavigator, "Unknown value type");
            return(true);
        }
 public override bool MoveNext()
 {
     XPathNavigator n = _query.Advance();
     if (n != null)
     {
         _position++;
         if (!_nav.MoveTo(n))
         {
             _nav = n.Clone();
         }
         return true;
     }
     return false;
 }
Beispiel #10
0
        public override object Evaluate(XPathNodeIterator nodeIterator)
        {
            base.Evaluate(nodeIterator);

            while (input.Advance() != null)
            {
                _child.Evaluate(input);
                XPathNavigator node;
                while ((node = _child.Advance()) != null)
                {
                    Insert(outputBuffer, node);
                }
            }
            return(this);
        }
        public override bool MoveNext()
        {
            XPathNavigator n = query.Advance();

            if (n != null)
            {
                position++;
                if (!nav.MoveTo(n))
                {
                    nav = n.Clone();
                }
                return(true);
            }
            return(false);
        }
        public static void AssertQuery(Query query)
        {
            Debug.Assert(query != null, "AssertQuery(): query == null");
            if (query is FunctionQuery)
            {
                return;                         // Temp Fix. Functions (as document()) return now unordered sequences
            }
            query = Clone(query);
            XPathNavigator last = null;
            XPathNavigator curr;
            int            querySize  = query.Clone().Count;
            int            actualSize = 0;

            while ((curr = query.Advance()) != null)
            {
                if (curr.GetType().ToString() == "Microsoft.VisualStudio.Modeling.StoreNavigator")
                {
                    return;
                }
                if (curr.GetType().ToString() == "System.Xml.DataDocumentXPathNavigator")
                {
                    return;
                }
                Debug.Assert(curr == query.Current, "AssertQuery(): query.Advance() != query.Current");
                if (last != null)
                {
                    if (last.NodeType == XPathNodeType.Namespace && curr.NodeType == XPathNodeType.Namespace)
                    {
                        // NamespaceQuery reports namsespaces in mixed order.
                        // Ignore this for now.
                        // It seams that this doesn't breake other queries becasue NS can't have children
                    }
                    else
                    {
                        XmlNodeOrder cmp = CompareNodes(last, curr);
                        Debug.Assert(cmp == XmlNodeOrder.Before, "AssertQuery(): Wrong node order");
                    }
                }
                last = curr.Clone();
                actualSize++;
            }
            Debug.Assert(actualSize == querySize, "AssertQuery(): actualSize != querySize");
        }
Beispiel #13
0
        private void BuildResultsList()
        {
            int numSorts = _comparer.NumSorts;

            Debug.Assert(numSorts > 0, "Why was the sort query created?");

            XPathNavigator eNext;

            while ((eNext = _qyInput.Advance()) != null)
            {
                SortKey key = new SortKey(numSorts, /*originalPosition:*/ _results.Count, eNext.Clone());

                for (int j = 0; j < numSorts; j++)
                {
                    key[j] = _comparer.Expression(j).Evaluate(_qyInput);
                }

                _results.Add(key);
            }
            _results.Sort(_comparer);
        }
Beispiel #14
0
 public bool MoveNext()
 {
     _current = _opnd.Advance();
     return(_current != null);
 }
Beispiel #15
0
 public static void AssertQuery(Query query) {
     Debug.Assert(query != null, "AssertQuery(): query == null");
     if (query is FunctionQuery) return; // Temp Fix. Functions (as document()) return now unordered sequences
     query = Clone(query);
     XPathNavigator last = null;
     XPathNavigator curr;
     int querySize = query.Clone().Count;
     int actualSize = 0;
     while ((curr = query.Advance()) != null) {
         if (curr.GetType().ToString() == "Microsoft.VisualStudio.Modeling.StoreNavigator") return;
         if (curr.GetType().ToString() == "System.Xml.DataDocumentXPathNavigator") return;
         Debug.Assert(curr == query.Current, "AssertQuery(): query.Advance() != query.Current");
         if (last != null) {
             if (last.NodeType == XPathNodeType.Namespace && curr.NodeType == XPathNodeType.Namespace) {
                 // NamespaceQuery reports namsespaces in mixed order.
                 // Ignore this for now. 
                 // It seams that this doesn't breake other queries becasue NS can't have children
             } else {
                 XmlNodeOrder cmp = CompareNodes(last, curr);
                 Debug.Assert(cmp == XmlNodeOrder.Before, "AssertQuery(): Wrong node order");
             }
         }
         last = curr.Clone();
         actualSize++;
     }
     Debug.Assert(actualSize == querySize, "AssertQuery(): actualSize != querySize");
 }
Beispiel #16
0
 public bool MoveNext()
 {
     current = opnd.Advance();
     return(current != null);
 }