2
0
Эх сурвалжийг харах

2003-07-29 Piers Haken <[email protected]>

	* XPathNavigator.cs:
	* Expression.cs:
		add typesafe Evaluate* methods

svn path=/trunk/mcs/; revision=16870
Piers Haken 22 жил өмнө
parent
commit
8e1cfb092b

+ 6 - 0
mcs/class/System.XML/System.Xml.XPath/ChangeLog

@@ -1,3 +1,9 @@
+2003-07-29 Piers Haken	<[email protected]>
+
+	* XPathNavigator.cs:
+	* Expression.cs:
+		add typesafe Evaluate* methods
+
 2003-07-29 Piers Haken	<[email protected]>
 
 	* DefaultContext.cs: fix 'substring-after'

+ 45 - 0
mcs/class/System.XML/System.Xml.XPath/Expression.cs

@@ -87,6 +87,51 @@ namespace System.Xml.XPath
 				throw new XPathException ("Error during evaluation", e);
 			}
 		}
+		public double EvaluateNumber (BaseIterator iter)
+		{
+			try
+			{
+				return _expr.EvaluateNumber (iter);
+			}
+			catch (XPathException)
+			{
+				throw;
+			}
+			catch (Exception e)
+			{
+				throw new XPathException ("Error during evaluation", e);
+			}
+		}
+		public string EvaluateString (BaseIterator iter)
+		{
+			try
+			{
+				return _expr.EvaluateString (iter);
+			}
+			catch (XPathException)
+			{
+				throw;
+			}
+			catch (Exception e)
+			{
+				throw new XPathException ("Error during evaluation", e);
+			}
+		}
+		public bool EvaluateBoolean (BaseIterator iter)
+		{
+			try
+			{
+				return _expr.EvaluateBoolean (iter);
+			}
+			catch (XPathException)
+			{
+				throw;
+			}
+			catch (Exception e)
+			{
+				throw new XPathException ("Error during evaluation", e);
+			}
+		}
 
 		public override void AddSort (Object obj, IComparer cmp)
 		{

+ 40 - 0
mcs/class/System.XML/System.Xml.XPath/XPathNavigator.cs

@@ -173,6 +173,46 @@ namespace System.Xml.XPath
 			return cexpr.Evaluate (iterContext);
 		}
 
+		internal XPathNodeIterator EvaluateNodeSet (XPathExpression expr, XPathNodeIterator context)
+		{
+			CompiledExpression cexpr = (CompiledExpression) expr;
+			if (context == null)
+				context = new NullIterator (this, cexpr.NamespaceManager);
+			BaseIterator iterContext = (BaseIterator) context;
+			iterContext.NamespaceManager = cexpr.NamespaceManager;
+			return cexpr.EvaluateNodeSet (iterContext);
+		}
+
+		internal string EvaluateString (XPathExpression expr, XPathNodeIterator context)
+		{
+			CompiledExpression cexpr = (CompiledExpression) expr;
+			if (context == null)
+				context = new NullIterator (this, cexpr.NamespaceManager);
+			BaseIterator iterContext = (BaseIterator) context;
+			iterContext.NamespaceManager = cexpr.NamespaceManager;
+			return cexpr.EvaluateString (iterContext);
+		}
+
+		internal double EvaluateNumber (XPathExpression expr, XPathNodeIterator context)
+		{
+			CompiledExpression cexpr = (CompiledExpression) expr;
+			if (context == null)
+				context = new NullIterator (this, cexpr.NamespaceManager);
+			BaseIterator iterContext = (BaseIterator) context;
+			iterContext.NamespaceManager = cexpr.NamespaceManager;
+			return cexpr.EvaluateNumber (iterContext);
+		}
+
+		internal bool EvaluateBoolean (XPathExpression expr, XPathNodeIterator context)
+		{
+			CompiledExpression cexpr = (CompiledExpression) expr;
+			if (context == null)
+				context = new NullIterator (this, cexpr.NamespaceManager);
+			BaseIterator iterContext = (BaseIterator) context;
+			iterContext.NamespaceManager = cexpr.NamespaceManager;
+			return cexpr.EvaluateBoolean (iterContext);
+		}
+
 		public abstract string GetAttribute (string localName, string namespaceURI);
 
 		public abstract string GetNamespace (string name);