public static TypeConverter GetConverter(Type type) { if (type == null) { throw new ArgumentNullException("type"); } var attributes = type.GetCustomAttributes( typeof(TypeConverterAttribute), true); if (attributes.Length > 0) { return(( TypeConverter )Activator.CreateInstance( Type.GetType( ((TypeConverterAttribute)attributes[0]).ConverterTypeName, true) )); } if (DefaultConverters.ContainsKey(type)) { return(( TypeConverter ) Activator.CreateInstance(DefaultConverters[type])); } return(null); }