Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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));
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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;
        }
Ejemplo n.º 5
0
 public static bool IsSerializable(object provider)
 {
     return(JsonTypeReflector.GetCachedAttribute <SerializableAttribute>(provider) != null);
 }