public JsonArrayContract(Type underlyingType) : base(underlyingType) { bool flag; base.enum15_0 = Enum15.Array; if (base.CreatedType.IsArray) { this.CollectionItemType = Class194.smethod_18(base.UnderlyingType); base.bool_4 = true; this.type_3 = typeof(List <>).MakeGenericType(new Type[] { this.CollectionItemType }); flag = true; this.IsMultidimensionalArray = base.UnderlyingType.IsArray && (base.UnderlyingType.GetArrayRank() > 1); } else if (typeof(IList).IsAssignableFrom(underlyingType)) { if (Class194.smethod_14(underlyingType, typeof(ICollection <>), out this.type_3)) { this.CollectionItemType = this.type_3.GetGenericArguments()[0]; } else { this.CollectionItemType = Class194.smethod_18(underlyingType); } if (underlyingType == typeof(IList)) { base.CreatedType = typeof(List <object>); } if (this.CollectionItemType != null) { this.ConstructorInfo_0 = Class191.smethod_3(underlyingType, this.CollectionItemType); } base.bool_4 = Class194.smethod_15(underlyingType, typeof(ReadOnlyCollection <>)); flag = true; } else if (Class194.smethod_14(underlyingType, typeof(ICollection <>), out this.type_3)) { this.CollectionItemType = this.type_3.GetGenericArguments()[0]; if (Class194.smethod_12(underlyingType, typeof(ICollection <>)) || Class194.smethod_12(underlyingType, typeof(IList <>))) { base.CreatedType = typeof(List <>).MakeGenericType(new Type[] { this.CollectionItemType }); } if (Class194.smethod_12(underlyingType, typeof(ISet <>))) { base.CreatedType = typeof(HashSet <>).MakeGenericType(new Type[] { this.CollectionItemType }); } this.ConstructorInfo_0 = Class191.smethod_3(underlyingType, this.CollectionItemType); flag = true; this.Boolean_0 = true; } else { Type type; if (Class194.smethod_14(underlyingType, typeof(IEnumerable <>), out type)) { this.CollectionItemType = type.GetGenericArguments()[0]; if (Class194.smethod_12(base.UnderlyingType, typeof(IEnumerable <>))) { base.CreatedType = typeof(List <>).MakeGenericType(new Type[] { this.CollectionItemType }); } this.ConstructorInfo_0 = Class191.smethod_3(underlyingType, this.CollectionItemType); if (underlyingType.smethod_4() && (underlyingType.GetGenericTypeDefinition() == typeof(IEnumerable <>))) { this.type_3 = type; base.bool_4 = false; this.Boolean_0 = false; flag = true; } else { this.type_3 = typeof(List <>).MakeGenericType(new Type[] { this.CollectionItemType }); base.bool_4 = true; this.Boolean_0 = true; flag = this.ConstructorInfo_0 != null; } } else { flag = false; this.Boolean_0 = true; } } this.Boolean_1 = flag; if (this.CollectionItemType != null) { this.bool_7 = Class194.smethod_10(this.CollectionItemType); } }
private JsonSchema method_5(Type type_0, Required required_0, bool bool_0) { JsonConverter converter; Class134 class4 = new Class134 { type_0 = type_0 }; Class203.smethod_2(class4.type_0, "type"); string str = this.method_4(class4.type_0, false); string str2 = this.method_4(class4.type_0, true); if (!string.IsNullOrEmpty(str)) { JsonSchema schema = this.jsonSchemaResolver_0.GetSchema(str); if (schema != null) { if ((required_0 != Required.Always) && !smethod_0(schema.Type, JsonSchemaType.Null)) { schema.Type = ((JsonSchemaType)schema.Type) | JsonSchemaType.Null; } if (bool_0 && (schema.Required != true)) { schema.Required = true; } return(schema); } } if (this.ilist_0.Any <Class133>(new Func <Class133, bool>(class4.method_0))) { throw new JsonException("Unresolved circular reference for type '{0}'. Explicitly define an Id for the type using a JsonObject/JsonArray attribute or automatically generate a type Id using the UndefinedSchemaIdHandling property.".smethod_0(CultureInfo.InvariantCulture, class4.type_0)); } JsonContract contract = this.ContractResolver.ResolveContract(class4.type_0); if (((converter = contract.Converter) != null) || ((converter = contract.JsonConverter_0) != null)) { JsonSchema schema2 = converter.GetSchema(); if (schema2 != null) { return(schema2); } } this.method_0(new Class133(class4.type_0, new JsonSchema())); if (str2 != null) { this.JsonSchema_0.Id = str2; } if (bool_0) { this.JsonSchema_0.Required = true; } this.JsonSchema_0.Title = this.method_2(class4.type_0); this.JsonSchema_0.Description = this.method_3(class4.type_0); if (converter != null) { this.JsonSchema_0.Type = 0x7f; } else { switch (contract.enum15_0) { case Enum15.Object: this.JsonSchema_0.Type = new JsonSchemaType?(this.method_6(JsonSchemaType.Object, required_0)); this.JsonSchema_0.Id = this.method_4(class4.type_0, false); this.method_8(class4.type_0, (JsonObjectContract)contract); goto Label_04CD; case Enum15.Array: { this.JsonSchema_0.Type = new JsonSchemaType?(this.method_6(JsonSchemaType.Array, required_0)); this.JsonSchema_0.Id = this.method_4(class4.type_0, false); JsonArrayAttribute attribute = Class139.smethod_0(class4.type_0) as JsonArrayAttribute; bool flag = (attribute == null) || attribute.AllowNullItems; Type type = Class194.smethod_18(class4.type_0); if (type != null) { this.JsonSchema_0.Items = new List <JsonSchema>(); this.JsonSchema_0.Items.Add(this.method_5(type, !flag ? Required.Always : Required.Default, false)); } goto Label_04CD; } case Enum15.Primitive: this.JsonSchema_0.Type = new JsonSchemaType?(this.method_10(class4.type_0, required_0)); if (((((JsonSchemaType)this.JsonSchema_0.Type) == JsonSchemaType.Integer) && class4.type_0.smethod_7()) && !class4.type_0.IsDefined(typeof(FlagsAttribute), true)) { this.JsonSchema_0.Enum = new List <JToken>(); foreach (Class187 <long> class3 in Class186.smethod_2 <long>(class4.type_0)) { JToken item = JToken.FromObject(class3.Prop_0); this.JsonSchema_0.Enum.Add(item); } } goto Label_04CD; case Enum15.String: { JsonSchemaType type2 = !Class194.smethod_9(contract.UnderlyingType) ? JsonSchemaType.String : this.method_6(JsonSchemaType.String, required_0); this.JsonSchema_0.Type = new JsonSchemaType?(type2); goto Label_04CD; } case Enum15.Dictionary: Type type3; Type type4; this.JsonSchema_0.Type = new JsonSchemaType?(this.method_6(JsonSchemaType.Object, required_0)); Class194.smethod_19(class4.type_0, out type3, out type4); if ((type3 != null) && (this.ContractResolver.ResolveContract(type3).enum15_0 == Enum15.Primitive)) { this.JsonSchema_0.AdditionalProperties = this.method_5(type4, Required.Default, false); } goto Label_04CD; case Enum15.Dynamic: case Enum15.Linq: this.JsonSchema_0.Type = 0x7f; goto Label_04CD; case Enum15.Serializable: this.JsonSchema_0.Type = new JsonSchemaType?(this.method_6(JsonSchemaType.Object, required_0)); this.JsonSchema_0.Id = this.method_4(class4.type_0, false); this.method_9(class4.type_0, (JsonISerializableContract)contract); goto Label_04CD; } throw new JsonException("Unexpected contract type: {0}".smethod_0(CultureInfo.InvariantCulture, contract)); } Label_04CD: return(this.method_1().JsonSchema_0); }