ソースを参照

2005-01-12 Gonzalo Paniagua Javier <[email protected]>

	* BaseNumberConverter.cs: when the culture we get is null, set it to the
	default. Fixes bug #67033. Thanks to Sander Rijken.


svn path=/trunk/mcs/; revision=38827
Gonzalo Paniagua Javier 21 年 前
コミット
b94fff0ad8

+ 8 - 2
mcs/class/System/System.ComponentModel/BaseNumberConverter.cs

@@ -46,7 +46,7 @@ namespace System.ComponentModel
 		public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
 		{
 			if (sourceType == typeof (string)) 
-			return true;
+				return true;
 			return base.CanConvertFrom (context, sourceType);
 		}
 
@@ -60,7 +60,10 @@ namespace System.ComponentModel
 
 		public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
 		{
-			if (value.GetType() == typeof (string)) {
+			if (culture == null)
+				culture = CultureInfo.CurrentCulture;
+
+			if (value is string) {
 				try {
 					return Convert.ChangeType (value, InnerType, culture.NumberFormat);
 				} catch (Exception e) {
@@ -80,6 +83,9 @@ namespace System.ComponentModel
 			if (value == null)
 				throw new ArgumentNullException ("value");
 
+			if (culture == null)
+				culture = CultureInfo.CurrentCulture;
+
 			if (destinationType == typeof (string) && value.GetType() == InnerType)
 				return Convert.ChangeType (value, typeof (string), culture.NumberFormat);
 

+ 5 - 0
mcs/class/System/System.ComponentModel/ChangeLog

@@ -1,3 +1,8 @@
+2005-01-12 Gonzalo Paniagua Javier <[email protected]>
+
+	* BaseNumberConverter.cs: when the culture we get is null, set it to the
+	default. Fixes bug #67033. Thanks to Sander Rijken.
+
 2005-01-10  LLuis Sanchez Gual  <[email protected]>
 
 	* BindingDirection.cs: New enum.