public override object Evaluate(BaseIterator iter) { String strArgs; object val = arg0.Evaluate(iter); XPathNodeIterator valItr = val as XPathNodeIterator; if (valItr != null) { strArgs = ""; while (valItr.MoveNext()) { strArgs += valItr.Current.Value + " "; } } else { strArgs = XPathFunctions.ToString(val); } XPathNavigator n = iter.Current.Clone(); ArrayList rgNodes = new ArrayList(); string [] ids = strArgs.Split(rgchWhitespace); for (int i = 0; i < ids.Length; i++) { if (n.MoveToId(ids [i])) { rgNodes.Add(n.Clone()); } } rgNodes.Sort(XPathNavigatorComparer.Instance); return(new ListIterator(iter, rgNodes)); }
public override object Evaluate(BaseIterator iter) { object obj = this.arg0.Evaluate(iter); XPathNodeIterator xpathNodeIterator = obj as XPathNodeIterator; string text; if (xpathNodeIterator != null) { text = string.Empty; while (xpathNodeIterator.MoveNext()) { XPathNavigator xpathNavigator = xpathNodeIterator.Current; text = text + xpathNavigator.Value + " "; } } else { text = XPathFunctions.ToString(obj); } XPathNavigator xpathNavigator2 = iter.Current.Clone(); ArrayList arrayList = new ArrayList(); string[] array = text.Split(XPathFunctionId.rgchWhitespace); for (int i = 0; i < array.Length; i++) { if (xpathNavigator2.MoveToId(array[i])) { arrayList.Add(xpathNavigator2.Clone()); } } arrayList.Sort(XPathNavigatorComparer.Instance); return(new ListIterator(iter, arrayList)); }
public static double ToNumber(object arg) { if (arg == null) { throw new ArgumentNullException(); } if (arg is BaseIterator || arg is XPathNavigator) { arg = XPathFunctions.ToString(arg); } if (arg is string) { string arg2 = arg as string; return(XPathFunctions.ToNumber(arg2)); } if (arg is double) { return((double)arg); } if (arg is bool) { return(Convert.ToDouble((bool)arg)); } throw new ArgumentException(); }
public virtual string EvaluateString(BaseIterator iter) { object obj = this.Evaluate(iter); XPathResultType returnType = this.GetReturnType(iter); if (returnType == XPathResultType.Any) { returnType = Expression.GetReturnType(obj); } switch (returnType) { case XPathResultType.Number: { double d = (double)obj; return(XPathFunctions.ToString(d)); } case XPathResultType.String: return((string)obj); case XPathResultType.Boolean: return((!(bool)obj) ? "false" : "true"); case XPathResultType.NodeSet: { BaseIterator baseIterator = (BaseIterator)obj; if (baseIterator == null || !baseIterator.MoveNext()) { return(string.Empty); } return(baseIterator.Current.Value); } case XPathResultType.Navigator: return(((XPathNavigator)obj).Value); default: throw new XPathException("invalid node type"); } }
public static string ToString(object arg) { if (arg == null) { throw new ArgumentNullException(); } if (arg is string) { return((string)arg); } if (arg is bool) { return((!(bool)arg) ? "false" : "true"); } if (arg is double) { return(XPathFunctions.ToString((double)arg)); } if (arg is XPathNodeIterator) { XPathNodeIterator xpathNodeIterator = (XPathNodeIterator)arg; if (!xpathNodeIterator.MoveNext()) { return(string.Empty); } return(xpathNodeIterator.Current.Value); } else { if (arg is XPathNavigator) { return(((XPathNavigator)arg).Value); } throw new ArgumentException(); } }
public override bool EvaluateBoolean(BaseIterator iter) { XPathResultType xpathResultType = this._left.GetReturnType(iter); XPathResultType xpathResultType2 = this._right.GetReturnType(iter); if (xpathResultType == XPathResultType.Any) { xpathResultType = Expression.GetReturnType(this._left.Evaluate(iter)); } if (xpathResultType2 == XPathResultType.Any) { xpathResultType2 = Expression.GetReturnType(this._right.Evaluate(iter)); } if (xpathResultType == XPathResultType.Navigator) { xpathResultType = XPathResultType.String; } if (xpathResultType2 == XPathResultType.Navigator) { xpathResultType2 = XPathResultType.String; } if (xpathResultType == XPathResultType.NodeSet || xpathResultType2 == XPathResultType.NodeSet) { Expression expression; Expression expression2; if (xpathResultType != XPathResultType.NodeSet) { expression = this._right; expression2 = this._left; XPathResultType xpathResultType3 = xpathResultType; xpathResultType2 = xpathResultType3; } else { expression = this._left; expression2 = this._right; } if (xpathResultType2 == XPathResultType.Boolean) { return(expression.EvaluateBoolean(iter) == expression2.EvaluateBoolean(iter) == this.trueVal); } BaseIterator baseIterator = expression.EvaluateNodeSet(iter); if (xpathResultType2 == XPathResultType.Number) { double num = expression2.EvaluateNumber(iter); while (baseIterator.MoveNext()) { if (XPathFunctions.ToNumber(baseIterator.Current.Value) == num == this.trueVal) { return(true); } } } else if (xpathResultType2 == XPathResultType.String) { string b = expression2.EvaluateString(iter); while (baseIterator.MoveNext()) { if (baseIterator.Current.Value == b == this.trueVal) { return(true); } } } else if (xpathResultType2 == XPathResultType.NodeSet) { BaseIterator baseIterator2 = expression2.EvaluateNodeSet(iter); ArrayList arrayList = new ArrayList(); while (baseIterator.MoveNext()) { XPathNavigator xpathNavigator = baseIterator.Current; arrayList.Add(XPathFunctions.ToString(xpathNavigator.Value)); } while (baseIterator2.MoveNext()) { XPathNavigator xpathNavigator2 = baseIterator2.Current; string a = XPathFunctions.ToString(xpathNavigator2.Value); for (int i = 0; i < arrayList.Count; i++) { if (a == (string)arrayList[i] == this.trueVal) { return(true); } } } } return(false); } else { if (xpathResultType == XPathResultType.Boolean || xpathResultType2 == XPathResultType.Boolean) { return(this._left.EvaluateBoolean(iter) == this._right.EvaluateBoolean(iter) == this.trueVal); } if (xpathResultType == XPathResultType.Number || xpathResultType2 == XPathResultType.Number) { return(this._left.EvaluateNumber(iter) == this._right.EvaluateNumber(iter) == this.trueVal); } return(this._left.EvaluateString(iter) == this._right.EvaluateString(iter) == this.trueVal); } }