コード例 #1
0
        protected virtual JsonContract CreateContract(Type objectType)
        {
            Type type = Class194.smethod_11(objectType);

            if (smethod_0(objectType))
            {
                return(this.CreatePrimitiveContract(objectType));
            }
            if (Class139.smethod_1(type) == null)
            {
                if (Class139.smethod_2(type) != null)
                {
                    return(this.CreateArrayContract(objectType));
                }
                if (Class139.smethod_3(type) != null)
                {
                    return(this.CreateDictionaryContract(objectType));
                }
                if ((type == typeof(JToken)) || type.IsSubclassOf(typeof(JToken)))
                {
                    return(this.CreateLinqContract(objectType));
                }
                if (Class191.smethod_2(type))
                {
                    return(this.CreateDictionaryContract(objectType));
                }
                if (typeof(IEnumerable).IsAssignableFrom(type))
                {
                    return(this.CreateArrayContract(objectType));
                }
                if (smethod_2(type))
                {
                    return(this.CreateStringContract(objectType));
                }
                if (!this.IgnoreSerializableInterface && typeof(ISerializable).IsAssignableFrom(type))
                {
                    return(this.CreateISerializableContract(objectType));
                }
                if (typeof(IDynamicMetaObjectProvider).IsAssignableFrom(type))
                {
                    return(this.CreateDynamicContract(objectType));
                }
                if (smethod_1(type))
                {
                    return(this.CreatePrimitiveContract(type));
                }
            }
            return(this.CreateObjectContract(objectType));
        }
コード例 #2
0
        protected virtual JsonObjectContract CreateObjectContract(Type objectType)
        {
            JsonObjectContract contract = new JsonObjectContract(objectType);

            this.method_7(contract);
            bool ignoreSerializableAttribute = this.IgnoreSerializableAttribute;

            contract.MemberSerialization = Class139.smethod_7(contract.type_0, ignoreSerializableAttribute);
            contract.Properties.smethod_1 <JsonProperty>(this.CreateProperties(contract.type_0, contract.MemberSerialization));
            JsonObjectAttribute attribute = Class139.smethod_1(contract.type_0);

            if (attribute != null)
            {
                contract.ItemRequired = attribute.nullable_4;
            }
            ConstructorInfo constructor = this.method_4(contract.type_0);

            if (constructor != null)
            {
                contract.OverrideConstructor = constructor;
                contract.ConstructorParameters.smethod_1 <JsonProperty>(this.CreateConstructorParameters(constructor, contract.Properties));
            }
            else if (contract.MemberSerialization == MemberSerialization.Fields)
            {
                if (Class139.Boolean_1)
                {
                    contract.DefaultCreator = new Func <object>(contract.method_5);
                }
            }
            else if ((contract.DefaultCreator == null) || contract.DefaultCreatorNonPublic)
            {
                ConstructorInfo info2 = this.method_5(contract.type_0);
                if (info2 != null)
                {
                    contract.ParametrizedConstructor = info2;
                    contract.ConstructorParameters.smethod_1 <JsonProperty>(this.CreateConstructorParameters(info2, contract.Properties));
                }
            }
            contract.ExtensionDataSetter = this.method_3(contract.type_0);
            return(contract);
        }