/// <summary> /// Extends ConvertTo so that methods that return a specific type object given a Type parameter can be /// used as generic method and casting is not required. /// <example> /// typeconverter.ConvertTo<int>(value); /// </example> /// </summary> public static T ConvertTo <T>(this CultureInfoConverter typeconverter, Object value) { if (typeconverter == null) { throw new ArgumentNullException("typeconverter"); } return((T)typeconverter.ConvertTo(value, typeof(T))); }
/// <summary> /// Extends ConvertTo so that methods that return a specific type object given a Type parameter can be /// used as generic method and casting is not required. /// <example> /// cultureinfoconverter.ConvertTo<int>(context, culture, value); /// </example> /// </summary> public static T ConvertTo <T>(this CultureInfoConverter cultureinfoconverter, ITypeDescriptorContext context, System.Globalization.CultureInfo culture, Object value) { if (cultureinfoconverter == null) { throw new ArgumentNullException("cultureinfoconverter"); } return((T)cultureinfoconverter.ConvertTo(context, culture, value, typeof(T))); }
internal static string ConvertToString(CultureInfo cultureInfo) { string result = new CultureInfoConverter().ConvertToInvariantString(cultureInfo); if (String.IsNullOrWhiteSpace(result)) { result = "neutral"; } return(result); }
private JsonFxAOT() { TypeConverter c; c = new ArrayConverter(); m_fakeFlag = c.Equals(c); //c = new BaseNumberConverter(); //m_fakeFlag = c.Equals(c); c = new BooleanConverter(); m_fakeFlag = c.Equals(c); c = new ByteConverter(); m_fakeFlag = c.Equals(c); c = new CollectionConverter(); m_fakeFlag = c.Equals(c); c = new ComponentConverter(typeof(int)); m_fakeFlag = c.Equals(c); c = new CultureInfoConverter(); m_fakeFlag = c.Equals(c); c = new DateTimeConverter(); m_fakeFlag = c.Equals(c); c = new DecimalConverter(); m_fakeFlag = c.Equals(c); c = new DoubleConverter(); m_fakeFlag = c.Equals(c); c = new EnumConverter(typeof(int)); m_fakeFlag = c.Equals(c); c = new ExpandableObjectConverter(); m_fakeFlag = c.Equals(c); c = new Int16Converter(); m_fakeFlag = c.Equals(c); c = new Int32Converter(); m_fakeFlag = c.Equals(c); c = new Int64Converter(); m_fakeFlag = c.Equals(c); c = new NullableConverter(typeof(object)); m_fakeFlag = c.Equals(c); c = new SByteConverter(); m_fakeFlag = c.Equals(c); c = new SingleConverter(); m_fakeFlag = c.Equals(c); c = new StringConverter(); m_fakeFlag = c.Equals(c); c = new TimeSpanConverter(); m_fakeFlag = c.Equals(c); c = new UInt16Converter(); m_fakeFlag = c.Equals(c); c = new UInt32Converter(); m_fakeFlag = c.Equals(c); c = new UInt64Converter(); m_fakeFlag = c.Equals(c); }
/// <summary> /// Return a list of the current design time cultures /// </summary> /// <returns></returns> static internal List <CultureInfo> GetDesignTimeCultures() { List <CultureInfo> result = new List <CultureInfo>(); if (_assemblyProbingPaths != null) { foreach (string path in _assemblyProbingPaths) { string[] subDirectories = Directory.GetDirectories(path); CultureInfoConverter converter = new CultureInfoConverter(); foreach (string subDirectory in subDirectories) { CultureInfo culture = GetCulture(Path.GetFileName(subDirectory)); if (culture != null) { result.Add(culture); } } } } return(result); }
public void SetUp() { converter = new CultureInfoConverter(); }
public CultureInfoConverterTest() { converter = new CultureInfoConverter(); }
internal static TypeConverter GetCoreConverterFromCustomType(Type type) { TypeConverter result = null; if (type.IsEnum) { result = new EnumConverter(type); } else if (typeof(int).IsAssignableFrom(type)) { result = new Int32Converter(); } else if (typeof(short).IsAssignableFrom(type)) { result = new Int16Converter(); } else if (typeof(long).IsAssignableFrom(type)) { result = new Int64Converter(); } else if (typeof(uint).IsAssignableFrom(type)) { result = new UInt32Converter(); } else if (typeof(ushort).IsAssignableFrom(type)) { result = new UInt16Converter(); } else if (typeof(ulong).IsAssignableFrom(type)) { result = new UInt64Converter(); } else if (typeof(bool).IsAssignableFrom(type)) { result = new BooleanConverter(); } else if (typeof(double).IsAssignableFrom(type)) { result = new DoubleConverter(); } else if (typeof(float).IsAssignableFrom(type)) { result = new SingleConverter(); } else if (typeof(byte).IsAssignableFrom(type)) { result = new ByteConverter(); } else if (typeof(sbyte).IsAssignableFrom(type)) { result = new SByteConverter(); } else if (typeof(char).IsAssignableFrom(type)) { result = new CharConverter(); } else if (typeof(decimal).IsAssignableFrom(type)) { result = new DecimalConverter(); } else if (typeof(TimeSpan).IsAssignableFrom(type)) { result = new TimeSpanConverter(); } else if (typeof(Guid).IsAssignableFrom(type)) { result = new GuidConverter(); } else if (typeof(string).IsAssignableFrom(type)) { result = new StringConverter(); } else if (typeof(CultureInfo).IsAssignableFrom(type)) { result = new CultureInfoConverter(); } else if (typeof(Type).IsAssignableFrom(type)) { result = new TypeTypeConverter(); } else if (typeof(DateTime).IsAssignableFrom(type)) { result = new DateTimeConverter2(); } return(result); }
private static TypeConverter GetCoreConverterFromCoreType(Type type) { TypeConverter result = null; if (type == typeof(int)) { result = new Int32Converter(); } else if (type == typeof(short)) { result = new Int16Converter(); } else if (type == typeof(long)) { result = new Int64Converter(); } else if (type == typeof(uint)) { result = new UInt32Converter(); } else if (type == typeof(ushort)) { result = new UInt16Converter(); } else if (type == typeof(ulong)) { result = new UInt64Converter(); } else if (type == typeof(bool)) { result = new BooleanConverter(); } else if (type == typeof(double)) { result = new DoubleConverter(); } else if (type == typeof(float)) { result = new SingleConverter(); } else if (type == typeof(byte)) { result = new ByteConverter(); } else if (type == typeof(sbyte)) { result = new SByteConverter(); } else if (type == typeof(char)) { result = new CharConverter(); } else if (type == typeof(decimal)) { result = new DecimalConverter(); } else if (type == typeof(TimeSpan)) { result = new TimeSpanConverter(); } else if (type == typeof(Guid)) { result = new GuidConverter(); } else if (type == typeof(string)) { result = new StringConverter(); } else if (type == typeof(CultureInfo)) { result = new CultureInfoConverter(); } else if (type == typeof(Type)) { result = new TypeTypeConverter(); } else if (type == typeof(DateTime)) { result = new DateTimeConverter2(); } else if (ReflectionHelper.IsNullableType(type)) { result = new NullableConverter(type); } return(result); }
public CultureComparer(CultureInfoConverter cultureConverter) { Debug.Assert(cultureConverter != null); _converter = cultureConverter; }