K
kw
I'm getting different behavior from what I would expect and was hoping
someone could clue me in. At run time I need to examine a property of an
object for a custom TypeConverter, then use that converter on a value.
Here's the deal:
object[]
attrs=(object[])PropertyInfo.GetCustomAttributes(typeof(TypeConverterAttribu
te),false);
TypeConverterAttribute a = (TypeConverterAttribute)attrs[0];
Type t=Type.GetType(a.ConverterTypeName);
//ok up to this point. Note that Type t is in an external assembly (it
shouldn't matter)
TypeConverter tc=TypeDescriptor.GetConverter(t);
Debug.WriteLine(tc.ConvertToString(this,vValue));
//it didn't work?! The TypeConverter never got invoked.
I'm getting different behavior from what I would expect and was hoping
someone could clue me in. At run time I need to examine a property of an
object for a custom TypeConverter, then use that converter on a value.
Not that it should matter, but the TypeConverter I use looks like this:
public class FormatCurrency : StringConverter{...}
And the object property looks like this:
[TypeConverter(typeof(MyNameSpace.FormatCurrency))]
public Double CurrencyWithTypeConverter{..}
someone could clue me in. At run time I need to examine a property of an
object for a custom TypeConverter, then use that converter on a value.
Here's the deal:
object[]
attrs=(object[])PropertyInfo.GetCustomAttributes(typeof(TypeConverterAttribu
te),false);
TypeConverterAttribute a = (TypeConverterAttribute)attrs[0];
Type t=Type.GetType(a.ConverterTypeName);
//ok up to this point. Note that Type t is in an external assembly (it
shouldn't matter)
TypeConverter tc=TypeDescriptor.GetConverter(t);
Debug.WriteLine(tc.ConvertToString(this,vValue));
//it didn't work?! The TypeConverter never got invoked.
I'm getting different behavior from what I would expect and was hoping
someone could clue me in. At run time I need to examine a property of an
object for a custom TypeConverter, then use that converter on a value.
Not that it should matter, but the TypeConverter I use looks like this:
public class FormatCurrency : StringConverter{...}
And the object property looks like this:
[TypeConverter(typeof(MyNameSpace.FormatCurrency))]
public Double CurrencyWithTypeConverter{..}