private static Type GetJsonConverterTypeFromAttribute(ICustomAttributeProvider attributeProvider) { JsonConverterAttribute converterAttribute = GetAttribute <JsonConverterAttribute>(attributeProvider); return((converterAttribute != null) ? converterAttribute.ConverterType : null); }
private static Type GetTypeConverterTypeFromAttribute(ICustomAttributeProvider attributeProvider) { TypeConverterAttribute converterAttribute = GetAttribute <TypeConverterAttribute>(attributeProvider); if (converterAttribute == null) { return(null); } return(Type.GetType(converterAttribute.ConverterTypeName)); }
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); }
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)); }
private static Type GetTypeConverterType(ICustomAttributeProvider attributeProvider) { return(TypeConverterTypeCache.Get(attributeProvider)); }
public static T GetAttribute(ICustomAttributeProvider type) { return(TypeAttributeCache.Get(type)); }