Inheritance: ITypeConverter
Exemplo n.º 1
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;
        }
Exemplo n.º 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);
        }