+2005-02-05 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * TypeDescriptor.cs: fixed bug #71601. GetConverter should handle
+ TypeConverter derived classes that take a Type argument.
+
2005-01-27 LLuis Sanchez Gual <lluis@novell.com>
* DateTimeConverter.cs, CultureInfoConverter.cs, DecimalConverter.cs,
if (t == null)\r
t = FindConverterType (type);\r
\r
- if (t != null)
- return (TypeConverter) Activator.CreateInstance (t);
- else
- return new ReferenceConverter (type); // Default?
+ if (t != null) {
+ Exception exc = null;
+ try {
+ return (TypeConverter) Activator.CreateInstance (t);
+ } catch (MissingMethodException e) {
+ exc = e;
+ }
+
+ try {
+ return (TypeConverter) Activator.CreateInstance (t, new object [] {type});
+ } catch (MissingMethodException e) {
+ throw exc;
+ }
+ }
+
+ return new ReferenceConverter (type); // Default?
}\r
\r
private static Type FindConverterType (Type type)\r
+2005-02-05 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * TypeDescriptorTests.cs: new test for TypeConverter ctor that takes
+ a Type argument.
+
2005-01-24 Joerg Rosenkranz (joergr@voelcker.com)
* TypeDescriptorTests.cs: Added tests for bug #71444
Assert ("t6.2", col.Find ("AnotherProperty", true) == null);
}
+ [TypeConverter (typeof (TestConverter))]
+ class TestConverterClass {
+ }
+
+ class TestConverter : TypeConverter {
+ public Type Type;
+
+ public TestConverter (Type type)
+ {
+ this.Type = type;
+ }
+ }
+
+ [Test]
+ public void TestConverterCtorWithArgument ()
+ {
+ TypeConverter t = TypeDescriptor.GetConverter (typeof (TestConverterClass));
+ Assert ("#01", null != t.GetType ());
+ AssertEquals ("#02", typeof (TestConverter), t.GetType ());
+ TestConverter converter = (TestConverter) t;
+ AssertEquals ("#03", typeof (TestConverterClass), converter.Type);
+ }
}
}