public NullableConverter(Type type) { this.nullableType = type; this.simpleType = Nullable.GetUnderlyingType(type); if (this.simpleType == null) { throw new ArgumentException(TC.NullableConverterBadCtorArg, "type"); } this.simpleTypeConverter = TypeConverterRegistry.GetConverter(this.simpleType); }
public static object ToType(object source, Type targetType) { ITypeConverter typeConverter = TypeConverterRegistry.GetConverter(targetType); if (typeConverter == null) { return(Convert.ChangeType(source, targetType)); } return(typeConverter.ConvertFrom(source)); }