X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fclass%2FSystem.Web%2FSystem.Web.UI%2FXPathBinder.cs;h=135edad6a4b7007d5292ee1bfd2eb6a648742776;hb=f212360d708424829d3e65fb1b0ae33849931e0a;hp=69cdb9af6f8dbe7b1bd70f6934e4e790ed3afdc4;hpb=b5cfba1835f2ba823796f825410e0062b7e4c9a3;p=mono.git diff --git a/mcs/class/System.Web/System.Web.UI/XPathBinder.cs b/mcs/class/System.Web/System.Web.UI/XPathBinder.cs index 69cdb9af6f8..135edad6a4b 100644 --- a/mcs/class/System.Web/System.Web.UI/XPathBinder.cs +++ b/mcs/class/System.Web/System.Web.UI/XPathBinder.cs @@ -28,54 +28,71 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -#if NET_2_0 using System.Collections; using System.Collections.Specialized; using System.Text; using System.Xml.XPath; using System.Xml; -namespace System.Web.UI { - public sealed class XPathBinder { - private XPathBinder () +namespace System.Web.UI +{ + public sealed class XPathBinder + { + XPathBinder () { } - + public static object Eval (object container, string xpath) + { + return Eval (container, xpath, (IXmlNamespaceResolver)null); + } + + public static object Eval (object container, string xpath, IXmlNamespaceResolver resolver) { if (xpath == null || xpath.Length == 0) throw new ArgumentNullException ("xpath"); - + IXPathNavigable factory = container as IXPathNavigable; - + if (factory == null) throw new ArgumentException ("container"); - - object result = factory.CreateNavigator ().Evaluate (xpath); - + + object result = factory.CreateNavigator ().Evaluate (xpath, resolver); + XPathNodeIterator itr = result as XPathNodeIterator; if (itr != null) { - if (itr.MoveNext()) + if (itr.MoveNext ()) return itr.Current.Value; else return null; } + return result; } - + public static string Eval (object container, string xpath, string format) { - object result = Eval (container, xpath); + return Eval (container, xpath, format, null); + } + + public static string Eval (object container, string xpath, string format, IXmlNamespaceResolver resolver) + { + object result = Eval (container, xpath, resolver); if (result == null) return String.Empty; if (format == null || format.Length == 0) return result.ToString (); - + return String.Format (format, result); } public static IEnumerable Select (object container, string xpath) + { + return Select (container, xpath, null); + } + + public static IEnumerable Select (object container, string xpath, IXmlNamespaceResolver resolver) { if (xpath == null || xpath.Length == 0) throw new ArgumentNullException ("xpath"); @@ -85,7 +102,7 @@ namespace System.Web.UI { if (factory == null) throw new ArgumentException ("container"); - XPathNodeIterator itr = factory.CreateNavigator ().Select (xpath); + XPathNodeIterator itr = factory.CreateNavigator ().Select (xpath, resolver); ArrayList ret = new ArrayList (); while (itr.MoveNext ()) { @@ -99,5 +116,4 @@ namespace System.Web.UI { } } -#endif