diff options
author | Atsushi Eno <atsushieno@gmail.com> | 2009-09-15 17:20:14 +0400 |
---|---|---|
committer | Atsushi Eno <atsushieno@gmail.com> | 2009-09-15 17:20:14 +0400 |
commit | 41d459231cc7c74be9248ff1aea6427a9c6dfb16 (patch) | |
tree | 9712a67b7aaa7c8ce3809d8c9e5bb3333cb84062 /mcs/class/System.XML/System.Xml.XPath | |
parent | 7c2b88b9fe481029a3fbdf34b835b2e6648532f4 (diff) |
2009-09-15 Atsushi Enomoto <atsushi@ximian.com>
* Expression.cs : to support external function that returns non-
double (such as int) as number, add conversion from non-double at
evaluation. This should fix bug #498389.
svn path=/trunk/mcs/; revision=141965
Diffstat (limited to 'mcs/class/System.XML/System.Xml.XPath')
-rw-r--r-- | mcs/class/System.XML/System.Xml.XPath/ChangeLog | 6 | ||||
-rw-r--r-- | mcs/class/System.XML/System.Xml.XPath/Expression.cs | 7 |
2 files changed, 12 insertions, 1 deletions
diff --git a/mcs/class/System.XML/System.Xml.XPath/ChangeLog b/mcs/class/System.XML/System.Xml.XPath/ChangeLog index bd83eede4a0..8d2802799f0 100644 --- a/mcs/class/System.XML/System.Xml.XPath/ChangeLog +++ b/mcs/class/System.XML/System.Xml.XPath/ChangeLog @@ -1,3 +1,9 @@ +2009-09-15 Atsushi Enomoto <atsushi@ximian.com> + + * Expression.cs : to support external function that returns non- + double (such as int) as number, add conversion from non-double at + evaluation. This should fix bug #498389. + 2009-07-22 Atsushi Enomoto <atsushi@ximian.com> * XPathNavigator.cs : name test did not handle String.Empty cases diff --git a/mcs/class/System.XML/System.Xml.XPath/Expression.cs b/mcs/class/System.XML/System.Xml.XPath/Expression.cs index a15ac919595..f61dda0c369 100644 --- a/mcs/class/System.XML/System.Xml.XPath/Expression.cs +++ b/mcs/class/System.XML/System.Xml.XPath/Expression.cs @@ -576,7 +576,12 @@ namespace System.Xml.XPath switch (type) { case XPathResultType.Number: - return (double)result; + if (result is double) + return (double)result; + else if (result is IConvertible) + return ((IConvertible) result).ToDouble (CultureInfo.InvariantCulture); + else + return (double) result; // most likely invalid cast case XPathResultType.Boolean: return ((bool) result) ? 1.0 : 0.0; case XPathResultType.NodeSet: |