Esempio n. 1
0
        private static Type GetJsonConverterTypeFromAttribute(ICustomAttributeProvider attributeProvider)
        {
            JsonConverterAttribute converterAttribute = GetAttribute <JsonConverterAttribute>(attributeProvider);

            return((converterAttribute != null)
        ? converterAttribute.ConverterType
        : null);
        }
Esempio n. 2
0
        private static Type GetTypeConverterTypeFromAttribute(ICustomAttributeProvider attributeProvider)
        {
            TypeConverterAttribute converterAttribute = GetAttribute <TypeConverterAttribute>(attributeProvider);

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

            return(Type.GetType(converterAttribute.ConverterTypeName));
        }
Esempio n. 3
0
        public static JsonConverter GetJsonConverter(ICustomAttributeProvider attributeProvider, Type targetConvertedType)
        {
            object provider = null;

#if !(NETFX_CORE || PORTABLE)
            provider = attributeProvider as MemberInfo;
#else
            provider = attributeProvider.UnderlyingObject;
#endif

            Type converterType = GetJsonConverterType(attributeProvider);

            if (converterType != null)
            {
                JsonConverter memberConverter = JsonConverterAttribute.CreateJsonConverterInstance(converterType);

                return(memberConverter);
            }

            return(null);
        }
Esempio n. 4
0
        public static T GetAttribute <T>(ICustomAttributeProvider attributeProvider) where T : Attribute
        {
            object provider = null;

#if !(NETFX_CORE || PORTABLE)
            provider = attributeProvider;
#else
            provider = attributeProvider.UnderlyingObject;
#endif

            Type type = provider as Type;
            if (type != null)
            {
                return(GetAttribute <T>(type));
            }

            MemberInfo memberInfo = provider as MemberInfo;
            if (memberInfo != null)
            {
                return(GetAttribute <T>(memberInfo));
            }

            return(ReflectionUtils.GetAttribute <T>(attributeProvider, true));
        }
Esempio n. 5
0
 private static Type GetTypeConverterType(ICustomAttributeProvider attributeProvider)
 {
     return(TypeConverterTypeCache.Get(attributeProvider));
 }
Esempio n. 6
0
 public static T GetAttribute(ICustomAttributeProvider type)
 {
     return(TypeAttributeCache.Get(type));
 }