Author: gonzalo
Date: 2005-04-25 22:24:01 -0400 (Mon, 25 Apr 2005)
New Revision: 43571
Modified:
trunk/mcs/class/System/System.ComponentModel/ChangeLog
trunk/mcs/class/System/System.ComponentModel/DefaultValueAttribute.cs
Log:
2005-04-25 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>
* DefaultValueAttribute.cs: fixed the .ctor that takes a type and a
string. Previous implementation caused *lots* of exceptions being thrown
when processing WebControl types.
Modified: trunk/mcs/class/System/System.ComponentModel/ChangeLog
===================================================================
--- trunk/mcs/class/System/System.ComponentModel/ChangeLog 2005-04-26
01:34:49 UTC (rev 43570)
+++ trunk/mcs/class/System/System.ComponentModel/ChangeLog 2005-04-26
02:24:01 UTC (rev 43571)
@@ -1,3 +1,9 @@
+2005-04-25 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>
+
+ * DefaultValueAttribute.cs: fixed the .ctor that takes a type and a
+ string. Previous implementation caused *lots* of exceptions being thrown
+ when processing WebControl types.
+
2005-04-22 LLuis Sanchez Gual <[EMAIL PROTECTED]>
* AttributeCollection.cs: When checking if the list contains an
Modified: trunk/mcs/class/System/System.ComponentModel/DefaultValueAttribute.cs
===================================================================
--- trunk/mcs/class/System/System.ComponentModel/DefaultValueAttribute.cs
2005-04-26 01:34:49 UTC (rev 43570)
+++ trunk/mcs/class/System/System.ComponentModel/DefaultValueAttribute.cs
2005-04-26 02:24:01 UTC (rev 43571)
@@ -28,6 +28,7 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+using System.Globalization;
namespace System.ComponentModel
{
[AttributeUsage(AttributeTargets.All)]
@@ -88,13 +89,10 @@
public DefaultValueAttribute (Type type, string value)
{
- // TODO check if this implementation is correct
try {
- DefaultValue = Convert.ChangeType (value, type);
- }
- catch {
- DefaultValue = null;
- }
+ TypeConverter converter =
TypeDescriptor.GetConverter (type);
+ DefaultValue = converter.ConvertFromString
(null, CultureInfo.InvariantCulture, value);
+ } catch { }
}
public object Value {
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches