Inheritance: ITypeConverter
        public ITypeConverter GetTypeConverter(Type type)
        {
            var converter = fallback.GetTypeConverter(type);
            if (converter == null)
            {
                var typeConverterAttribute = type.GetTypeInfo().GetCustomAttribute<TypeConverterAttribute>();

                if (typeConverterAttribute == null)
                {
                    return null;
                }

                var qualifiedName = typeConverterAttribute.ConverterTypeName;
                var converterType = Type.GetType(qualifiedName, true);
                var converterInstance = (TypeConverter) Activator.CreateInstance(converterType);
                converter = new ConverterAdapter(converterInstance);
            }
            return converter;
        }
示例#2
0
        public ITypeConverter GetTypeConverter(Type type)
        {
            var converter = fallback.GetTypeConverter(type);

            if (converter == null)
            {
                var typeConverterAttribute = type.GetTypeInfo().GetCustomAttribute <TypeConverterAttribute>();

                if (typeConverterAttribute == null)
                {
                    return(null);
                }

                var qualifiedName     = typeConverterAttribute.ConverterTypeName;
                var converterType     = Type.GetType(qualifiedName, true);
                var converterInstance = (TypeConverter)Activator.CreateInstance(converterType);
                converter = new ConverterAdapter(converterInstance);
            }
            return(converter);
        }