コード例 #1
0
 public static bool ToBoolean(object arg)
 {
     if (arg == null)
     {
         throw new ArgumentNullException();
     }
     if (arg is bool)
     {
         return((bool)arg);
     }
     if (arg is double)
     {
         double num = (double)arg;
         return(num != 0.0 && !double.IsNaN(num));
     }
     if (arg is string)
     {
         return(((string)arg).Length != 0);
     }
     if (arg is XPathNodeIterator)
     {
         XPathNodeIterator xpathNodeIterator = (XPathNodeIterator)arg;
         return(xpathNodeIterator.MoveNext());
     }
     if (arg is XPathNavigator)
     {
         return(XPathFunctions.ToBoolean(((XPathNavigator)arg).SelectChildren(XPathNodeType.All)));
     }
     throw new ArgumentException();
 }
コード例 #2
0
 public override object Evaluate(BaseIterator iter)
 {
     if (arg0 == null)
     {
         return(XPathFunctions.ToBoolean(iter.Current.Value));
     }
     return(arg0.EvaluateBoolean(iter));
 }
コード例 #3
0
        public override bool MoveNextCore()
        {
            if (finished)
            {
                return(false);
            }
            while (_iter.MoveNext())
            {
                switch (resType)
                {
                case XPathResultType.Number:
                    if (_pred.EvaluateNumber(_iter) != _iter.ComparablePosition)
                    {
                        continue;
                    }
                    break;

                case XPathResultType.Any:
                {
                    object result = _pred.Evaluate(_iter);
                    if (result is double)
                    {
                        if ((double)result != _iter.ComparablePosition)
                        {
                            continue;
                        }
                    }
                    else if (!XPathFunctions.ToBoolean(result))
                    {
                        continue;
                    }
                }
                break;

                default:
                    if (!_pred.EvaluateBoolean(_iter))
                    {
                        continue;
                    }
                    break;
                }

                return(true);
            }
            finished = true;
            return(false);
        }
コード例 #4
0
 public override bool MoveNextCore()
 {
     if (this.finished)
     {
         return(false);
     }
     while (this._iter.MoveNext())
     {
         XPathResultType xpathResultType = this.resType;
         if (xpathResultType != XPathResultType.Number)
         {
             if (xpathResultType != XPathResultType.Any)
             {
                 if (!this._pred.EvaluateBoolean(this._iter))
                 {
                     continue;
                 }
             }
             else
             {
                 object obj = this._pred.Evaluate(this._iter);
                 if (obj is double)
                 {
                     if ((double)obj != (double)this._iter.ComparablePosition)
                     {
                         continue;
                     }
                 }
                 else if (!XPathFunctions.ToBoolean(obj))
                 {
                     continue;
                 }
             }
         }
         else if (this._pred.EvaluateNumber(this._iter) != (double)this._iter.ComparablePosition)
         {
             continue;
         }
         return(true);
     }
     this.finished = true;
     return(false);
 }