It looks like, internally, TypeConverter
handles the procurement of the required converter using a complicated nested if
statement. Something like (source):
internal static TypeConverter GetCoreConverterFromCustomType(Type type)
{
TypeConverter typeConverter = null;
if (type.IsEnum)
{
// Need to handle Enums types specially as they require a ctor that
// takes the underlying type.
typeConverter = new System.ComponentModel.EnumConverter(type);
}
else if (typeof(Int32).IsAssignableFrom(type))
{
typeConverter = new System.ComponentModel.Int32Converter();
}
else if (typeof(Int16).IsAssignableFrom(type))
{
typeConverter = new System.ComponentModel.Int16Converter();
}
//...
From the first if
statement you can see that it knows to pass the special Type
parameter into the constructor.
As an answer to the second question of can I create a custom TypeConverter
with a custom-parameterized constructor that will play nicely with TypeConverter
, it looks doubtful.