public static NamingStrategy GetContainerNamingStrategy( JsonContainerAttribute containerAttribute) { if (containerAttribute.NamingStrategyInstance == null) { if (containerAttribute.NamingStrategyType == null) { return((NamingStrategy)null); } containerAttribute.NamingStrategyInstance = JsonTypeReflector.CreateNamingStrategyInstance(containerAttribute.NamingStrategyType, containerAttribute.NamingStrategyParameters); } return(containerAttribute.NamingStrategyInstance); }
public static T GetAttribute <T>(object provider) where T : Attribute { Type type = provider as Type; if (type != null) { return(JsonTypeReflector.GetAttribute <T>(type)); } MemberInfo memberInfo = provider as MemberInfo; if (memberInfo != null) { return(JsonTypeReflector.GetAttribute <T>(memberInfo)); } return(ReflectionUtils.GetAttribute <T>(provider, true)); }
public static JsonConverter GetJsonConverter(object attributeProvider) { JsonConverterAttribute cachedAttribute = JsonTypeReflector.GetCachedAttribute <JsonConverterAttribute>(attributeProvider); if (cachedAttribute != null) { Func <object[], object> func = JsonTypeReflector.CreatorCache.Get(cachedAttribute.ConverterType); if (func != null) { return((JsonConverter)func(cachedAttribute.ConverterParameters)); } } return((JsonConverter)null); }
internal JsonContainerContract(Type underlyingType) : base(underlyingType) { JsonContainerAttribute cachedAttribute = JsonTypeReflector.GetCachedAttribute <JsonContainerAttribute>((object)underlyingType); if (cachedAttribute == null) { return; } if (cachedAttribute.ItemConverterType != null) { this.ItemConverter = JsonTypeReflector.CreateJsonConverterInstance(cachedAttribute.ItemConverterType, cachedAttribute.ItemConverterParameters); } this.ItemIsReference = cachedAttribute._itemIsReference; this.ItemReferenceLoopHandling = cachedAttribute._itemReferenceLoopHandling; this.ItemTypeNameHandling = cachedAttribute._itemTypeNameHandling; }
public static bool IsSerializable(object provider) { return(JsonTypeReflector.GetCachedAttribute <SerializableAttribute>(provider) != null); }