private static TypeConverter GetCoreConverterFromCoreType(Type type) { TypeConverter typeConverter = null; if (type == typeof(Int32)) { typeConverter = new System.ComponentModel.Int32Converter(); } else if (type == typeof(Int16)) { typeConverter = new System.ComponentModel.Int16Converter(); } else if (type == typeof(Int64)) { typeConverter = new System.ComponentModel.Int64Converter(); } else if (type == typeof(UInt32)) { typeConverter = new System.ComponentModel.UInt32Converter(); } else if (type == typeof(UInt16)) { typeConverter = new System.ComponentModel.UInt16Converter(); } else if (type == typeof(UInt64)) { typeConverter = new System.ComponentModel.UInt64Converter(); } else if (type == typeof(Boolean)) { typeConverter = new System.ComponentModel.BooleanConverter(); } else if (type == typeof(Double)) { typeConverter = new System.ComponentModel.DoubleConverter(); } else if (type == typeof(Single)) { typeConverter = new System.ComponentModel.SingleConverter(); } else if (type == typeof(Byte)) { typeConverter = new System.ComponentModel.ByteConverter(); } else if (type == typeof(SByte)) { typeConverter = new System.ComponentModel.SByteConverter(); } else if (type == typeof(Char)) { typeConverter = new System.ComponentModel.CharConverter(); } else if (type == typeof(Decimal)) { typeConverter = new System.ComponentModel.DecimalConverter(); } else if (type == typeof(TimeSpan)) { typeConverter = new System.ComponentModel.TimeSpanConverter(); } else if (type == typeof(Guid)) { typeConverter = new System.ComponentModel.GuidConverter(); } else if (type == typeof(String)) { typeConverter = new System.ComponentModel.StringConverter(); } else if (type == typeof(CultureInfo)) { typeConverter = new System.ComponentModel.CultureInfoConverter(); } #if !SYSTEM_XAML else if (type == typeof(Type)) { typeConverter = new System.Windows.Markup.TypeTypeConverter(); } #else else if (type == typeof(Type)) { typeConverter = new System.Xaml.Replacements.TypeTypeConverter(); } #endif else if (type == typeof(DateTime)) { typeConverter = new DateTimeConverter2(); } else if (ReflectionHelper.IsNullableType(type)) { typeConverter = new System.ComponentModel.NullableConverter(type); } return(typeConverter); }
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(); } else if (typeof(Int64).IsAssignableFrom(type)) { typeConverter = new System.ComponentModel.Int64Converter(); } else if (typeof(UInt32).IsAssignableFrom(type)) { typeConverter = new System.ComponentModel.UInt32Converter(); } else if (typeof(UInt16).IsAssignableFrom(type)) { typeConverter = new System.ComponentModel.UInt16Converter(); } else if (typeof(UInt64).IsAssignableFrom(type)) { typeConverter = new System.ComponentModel.UInt64Converter(); } else if (typeof(Boolean).IsAssignableFrom(type)) { typeConverter = new System.ComponentModel.BooleanConverter(); } else if (typeof(Double).IsAssignableFrom(type)) { typeConverter = new System.ComponentModel.DoubleConverter(); } else if (typeof(Single).IsAssignableFrom(type)) { typeConverter = new System.ComponentModel.SingleConverter(); } else if (typeof(Byte).IsAssignableFrom(type)) { typeConverter = new System.ComponentModel.ByteConverter(); } else if (typeof(SByte).IsAssignableFrom(type)) { typeConverter = new System.ComponentModel.SByteConverter(); } else if (typeof(Char).IsAssignableFrom(type)) { typeConverter = new System.ComponentModel.CharConverter(); } else if (typeof(Decimal).IsAssignableFrom(type)) { typeConverter = new System.ComponentModel.DecimalConverter(); } else if (typeof(TimeSpan).IsAssignableFrom(type)) { typeConverter = new System.ComponentModel.TimeSpanConverter(); } else if (typeof(Guid).IsAssignableFrom(type)) { typeConverter = new System.ComponentModel.GuidConverter(); } else if (typeof(String).IsAssignableFrom(type)) { typeConverter = new System.ComponentModel.StringConverter(); } else if (typeof(CultureInfo).IsAssignableFrom(type)) { typeConverter = new System.ComponentModel.CultureInfoConverter(); } #if !SYSTEM_XAML else if (typeof(Type).IsAssignableFrom(type)) { typeConverter = new System.Windows.Markup.TypeTypeConverter(); } #else else if (type == typeof(Type)) { typeConverter = new System.Xaml.Replacements.TypeTypeConverter(); } #endif else if (typeof(DateTime).IsAssignableFrom(type)) { typeConverter = new DateTimeConverter2(); } else if (typeof(Uri).IsAssignableFrom(type)) { typeConverter = new System.Xaml.Replacements.TypeUriConverter(); } return(typeConverter); }
internal static TypeConverter GetCoreConverterFromCustomType(Type type) { TypeConverter converter = null; if (type.IsEnum) { return(new EnumConverter(type)); } if (typeof(int).IsAssignableFrom(type)) { return(new Int32Converter()); } if (typeof(short).IsAssignableFrom(type)) { return(new Int16Converter()); } if (typeof(long).IsAssignableFrom(type)) { return(new Int64Converter()); } if (typeof(uint).IsAssignableFrom(type)) { return(new UInt32Converter()); } if (typeof(ushort).IsAssignableFrom(type)) { return(new UInt16Converter()); } if (typeof(ulong).IsAssignableFrom(type)) { return(new UInt64Converter()); } if (typeof(bool).IsAssignableFrom(type)) { return(new BooleanConverter()); } if (typeof(double).IsAssignableFrom(type)) { return(new DoubleConverter()); } if (typeof(float).IsAssignableFrom(type)) { return(new SingleConverter()); } if (typeof(byte).IsAssignableFrom(type)) { return(new ByteConverter()); } if (typeof(sbyte).IsAssignableFrom(type)) { return(new SByteConverter()); } if (typeof(char).IsAssignableFrom(type)) { return(new CharConverter()); } if (typeof(decimal).IsAssignableFrom(type)) { return(new DecimalConverter()); } if (typeof(TimeSpan).IsAssignableFrom(type)) { return(new TimeSpanConverter()); } if (typeof(Guid).IsAssignableFrom(type)) { return(new GuidConverter()); } if (typeof(string).IsAssignableFrom(type)) { return(new StringConverter()); } if (typeof(CultureInfo).IsAssignableFrom(type)) { return(new CultureInfoConverter()); } if (type == typeof(Type)) { return(new TypeTypeConverter()); } if (typeof(DateTime).IsAssignableFrom(type)) { converter = new DateTimeConverter2(); } return(converter); }