forked from loafle/openapi-generator-original
[C#][netcore] Add nullable support to oneOf models (#7750)
* add nullable support to C# oneOf models * fix null reference exception
This commit is contained in:
parent
12acf2eb72
commit
072b309100
@ -14,7 +14,7 @@ namespace {{packageName}}.{{modelPackage}}
|
||||
/// <summary>
|
||||
/// Custom JSON serializer
|
||||
/// </summary>
|
||||
protected readonly JsonSerializerSettings _serializerSettings = new JsonSerializerSettings
|
||||
static public readonly JsonSerializerSettings SerializerSettings = new JsonSerializerSettings
|
||||
{
|
||||
// OpenAPI generated types generally hide default constructors.
|
||||
ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor,
|
||||
|
@ -4,6 +4,7 @@
|
||||
[DataContract(Name = "{{{name}}}")]
|
||||
{{>visibility}} partial class {{classname}} : AbstractOpenAPISchema, {{#parent}}{{{parent}}}, {{/parent}}IEquatable<{{classname}}>{{#validatable}}, IValidatableObject{{/validatable}}
|
||||
{
|
||||
{{#isNullable}}
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="{{classname}}" /> class.
|
||||
/// </summary>
|
||||
@ -13,6 +14,7 @@
|
||||
this.SchemaType= "oneOf";
|
||||
}
|
||||
|
||||
{{/isNullable}}
|
||||
{{#oneOf}}
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="{{classname}}" /> class
|
||||
@ -85,7 +87,7 @@
|
||||
/// <returns>JSON string presentation of the object</returns>
|
||||
public override string ToJson()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this.ActualInstance, _serializerSettings);
|
||||
return JsonConvert.SerializeObject(this.ActualInstance, {{classname}}.SerializerSettings);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -95,7 +97,7 @@
|
||||
/// <returns>An instance of {{classname}}</returns>
|
||||
public static {{classname}} FromJson(string jsonString)
|
||||
{
|
||||
{{classname}} new{{classname}} = new {{classname}}();
|
||||
{{classname}} new{{classname}} = null;
|
||||
{{#useOneOfDiscriminatorLookup}}
|
||||
{{#discriminator}}
|
||||
|
||||
@ -104,11 +106,11 @@
|
||||
{
|
||||
{{#mappedModels}}
|
||||
case "{{{mappingName}}}":
|
||||
new{{classname}}.ActualInstance = JsonConvert.DeserializeObject<{{{modelName}}}>(jsonString, new{{classname}}._serializerSettings);
|
||||
new{{classname}} = new {{classname}}(JsonConvert.DeserializeObject<{{{modelName}}}>(jsonString, {{classname}}.SerializerSettings));
|
||||
return new{{classname}};
|
||||
{{/mappedModels}}
|
||||
default:
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to lookup discriminator value `%s` for {{classname}}. Possible values:{{#mappedModels}} {{{mappingName}}}{{/mappedModels}}", discriminatorValue));
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to lookup discriminator value `{0}` for {{classname}}. Possible values:{{#mappedModels}} {{{mappingName}}}{{/mappedModels}}", discriminatorValue));
|
||||
break;
|
||||
}
|
||||
|
||||
@ -120,14 +122,14 @@
|
||||
|
||||
try
|
||||
{
|
||||
new{{classname}}.ActualInstance = JsonConvert.DeserializeObject<{{{.}}}>(jsonString, new{{classname}}._serializerSettings);
|
||||
new{{classname}} = new {{classname}}(JsonConvert.DeserializeObject<{{{.}}}>(jsonString, {{classname}}.SerializerSettings));
|
||||
matchedTypes.Add("{{{.}}}");
|
||||
match++;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
// deserialization failed, try the next one
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `%s` into {{{.}}}: %s", jsonString, exception.ToString()));
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `{0}` into {{{.}}}: {1}", jsonString, exception.ToString()));
|
||||
}
|
||||
{{/oneOf}}
|
||||
|
||||
|
@ -68,7 +68,7 @@ namespace Org.OpenAPITools.Test
|
||||
t.Name = "Something";
|
||||
|
||||
Fruit f1 = new Fruit(a);
|
||||
Fruit f2 = new Fruit(a);
|
||||
Fruit f2 = new Fruit(b);
|
||||
|
||||
f1.ActualInstance = b;
|
||||
f2.ActualInstance = a;
|
||||
|
@ -22,7 +22,7 @@ namespace Org.OpenAPITools.Model
|
||||
/// <summary>
|
||||
/// Custom JSON serializer
|
||||
/// </summary>
|
||||
protected readonly JsonSerializerSettings _serializerSettings = new JsonSerializerSettings
|
||||
static public readonly JsonSerializerSettings SerializerSettings = new JsonSerializerSettings
|
||||
{
|
||||
// OpenAPI generated types generally hide default constructors.
|
||||
ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor,
|
||||
|
@ -32,15 +32,6 @@ namespace Org.OpenAPITools.Model
|
||||
[DataContract(Name = "fruit")]
|
||||
public partial class Fruit : AbstractOpenAPISchema, IEquatable<Fruit>, IValidatableObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Fruit" /> class.
|
||||
/// </summary>
|
||||
public Fruit()
|
||||
{
|
||||
this.IsNullable = true;
|
||||
this.SchemaType= "oneOf";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Fruit" /> class
|
||||
/// with the <see cref="Apple" /> class
|
||||
@ -133,7 +124,7 @@ namespace Org.OpenAPITools.Model
|
||||
/// <returns>JSON string presentation of the object</returns>
|
||||
public override string ToJson()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this.ActualInstance, _serializerSettings);
|
||||
return JsonConvert.SerializeObject(this.ActualInstance, Fruit.SerializerSettings);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -143,32 +134,32 @@ namespace Org.OpenAPITools.Model
|
||||
/// <returns>An instance of Fruit</returns>
|
||||
public static Fruit FromJson(string jsonString)
|
||||
{
|
||||
Fruit newFruit = new Fruit();
|
||||
Fruit newFruit = null;
|
||||
int match = 0;
|
||||
List<string> matchedTypes = new List<string>();
|
||||
|
||||
try
|
||||
{
|
||||
newFruit.ActualInstance = JsonConvert.DeserializeObject<Apple>(jsonString, newFruit._serializerSettings);
|
||||
newFruit = new Fruit(JsonConvert.DeserializeObject<Apple>(jsonString, Fruit.SerializerSettings));
|
||||
matchedTypes.Add("Apple");
|
||||
match++;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
// deserialization failed, try the next one
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `%s` into Apple: %s", jsonString, exception.ToString()));
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `{0}` into Apple: {1}", jsonString, exception.ToString()));
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
newFruit.ActualInstance = JsonConvert.DeserializeObject<Banana>(jsonString, newFruit._serializerSettings);
|
||||
newFruit = new Fruit(JsonConvert.DeserializeObject<Banana>(jsonString, Fruit.SerializerSettings));
|
||||
matchedTypes.Add("Banana");
|
||||
match++;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
// deserialization failed, try the next one
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `%s` into Banana: %s", jsonString, exception.ToString()));
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `{0}` into Banana: {1}", jsonString, exception.ToString()));
|
||||
}
|
||||
|
||||
if (match == 0)
|
||||
|
@ -133,7 +133,7 @@ namespace Org.OpenAPITools.Model
|
||||
/// <returns>JSON string presentation of the object</returns>
|
||||
public override string ToJson()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this.ActualInstance, _serializerSettings);
|
||||
return JsonConvert.SerializeObject(this.ActualInstance, FruitReq.SerializerSettings);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -143,32 +143,32 @@ namespace Org.OpenAPITools.Model
|
||||
/// <returns>An instance of FruitReq</returns>
|
||||
public static FruitReq FromJson(string jsonString)
|
||||
{
|
||||
FruitReq newFruitReq = new FruitReq();
|
||||
FruitReq newFruitReq = null;
|
||||
int match = 0;
|
||||
List<string> matchedTypes = new List<string>();
|
||||
|
||||
try
|
||||
{
|
||||
newFruitReq.ActualInstance = JsonConvert.DeserializeObject<AppleReq>(jsonString, newFruitReq._serializerSettings);
|
||||
newFruitReq = new FruitReq(JsonConvert.DeserializeObject<AppleReq>(jsonString, FruitReq.SerializerSettings));
|
||||
matchedTypes.Add("AppleReq");
|
||||
match++;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
// deserialization failed, try the next one
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `%s` into AppleReq: %s", jsonString, exception.ToString()));
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `{0}` into AppleReq: {1}", jsonString, exception.ToString()));
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
newFruitReq.ActualInstance = JsonConvert.DeserializeObject<BananaReq>(jsonString, newFruitReq._serializerSettings);
|
||||
newFruitReq = new FruitReq(JsonConvert.DeserializeObject<BananaReq>(jsonString, FruitReq.SerializerSettings));
|
||||
matchedTypes.Add("BananaReq");
|
||||
match++;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
// deserialization failed, try the next one
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `%s` into BananaReq: %s", jsonString, exception.ToString()));
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `{0}` into BananaReq: {1}", jsonString, exception.ToString()));
|
||||
}
|
||||
|
||||
if (match == 0)
|
||||
|
@ -33,15 +33,6 @@ namespace Org.OpenAPITools.Model
|
||||
[DataContract(Name = "mammal")]
|
||||
public partial class Mammal : AbstractOpenAPISchema, IEquatable<Mammal>, IValidatableObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Mammal" /> class.
|
||||
/// </summary>
|
||||
public Mammal()
|
||||
{
|
||||
this.IsNullable = true;
|
||||
this.SchemaType= "oneOf";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Mammal" /> class
|
||||
/// with the <see cref="Pig" /> class
|
||||
@ -160,7 +151,7 @@ namespace Org.OpenAPITools.Model
|
||||
/// <returns>JSON string presentation of the object</returns>
|
||||
public override string ToJson()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this.ActualInstance, _serializerSettings);
|
||||
return JsonConvert.SerializeObject(this.ActualInstance, Mammal.SerializerSettings);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -170,22 +161,22 @@ namespace Org.OpenAPITools.Model
|
||||
/// <returns>An instance of Mammal</returns>
|
||||
public static Mammal FromJson(string jsonString)
|
||||
{
|
||||
Mammal newMammal = new Mammal();
|
||||
Mammal newMammal = null;
|
||||
|
||||
string discriminatorValue = JObject.Parse(jsonString)["className"].ToString();
|
||||
switch (discriminatorValue)
|
||||
{
|
||||
case "Pig":
|
||||
newMammal.ActualInstance = JsonConvert.DeserializeObject<Pig>(jsonString, newMammal._serializerSettings);
|
||||
newMammal = new Mammal(JsonConvert.DeserializeObject<Pig>(jsonString, Mammal.SerializerSettings));
|
||||
return newMammal;
|
||||
case "whale":
|
||||
newMammal.ActualInstance = JsonConvert.DeserializeObject<Whale>(jsonString, newMammal._serializerSettings);
|
||||
newMammal = new Mammal(JsonConvert.DeserializeObject<Whale>(jsonString, Mammal.SerializerSettings));
|
||||
return newMammal;
|
||||
case "zebra":
|
||||
newMammal.ActualInstance = JsonConvert.DeserializeObject<Zebra>(jsonString, newMammal._serializerSettings);
|
||||
newMammal = new Mammal(JsonConvert.DeserializeObject<Zebra>(jsonString, Mammal.SerializerSettings));
|
||||
return newMammal;
|
||||
default:
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to lookup discriminator value `%s` for Mammal. Possible values: Pig whale zebra", discriminatorValue));
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to lookup discriminator value `{0}` for Mammal. Possible values: Pig whale zebra", discriminatorValue));
|
||||
break;
|
||||
}
|
||||
|
||||
@ -194,38 +185,38 @@ namespace Org.OpenAPITools.Model
|
||||
|
||||
try
|
||||
{
|
||||
newMammal.ActualInstance = JsonConvert.DeserializeObject<Pig>(jsonString, newMammal._serializerSettings);
|
||||
newMammal = new Mammal(JsonConvert.DeserializeObject<Pig>(jsonString, Mammal.SerializerSettings));
|
||||
matchedTypes.Add("Pig");
|
||||
match++;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
// deserialization failed, try the next one
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `%s` into Pig: %s", jsonString, exception.ToString()));
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `{0}` into Pig: {1}", jsonString, exception.ToString()));
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
newMammal.ActualInstance = JsonConvert.DeserializeObject<Whale>(jsonString, newMammal._serializerSettings);
|
||||
newMammal = new Mammal(JsonConvert.DeserializeObject<Whale>(jsonString, Mammal.SerializerSettings));
|
||||
matchedTypes.Add("Whale");
|
||||
match++;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
// deserialization failed, try the next one
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `%s` into Whale: %s", jsonString, exception.ToString()));
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `{0}` into Whale: {1}", jsonString, exception.ToString()));
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
newMammal.ActualInstance = JsonConvert.DeserializeObject<Zebra>(jsonString, newMammal._serializerSettings);
|
||||
newMammal = new Mammal(JsonConvert.DeserializeObject<Zebra>(jsonString, Mammal.SerializerSettings));
|
||||
matchedTypes.Add("Zebra");
|
||||
match++;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
// deserialization failed, try the next one
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `%s` into Zebra: %s", jsonString, exception.ToString()));
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `{0}` into Zebra: {1}", jsonString, exception.ToString()));
|
||||
}
|
||||
|
||||
if (match == 0)
|
||||
|
@ -134,7 +134,7 @@ namespace Org.OpenAPITools.Model
|
||||
/// <returns>JSON string presentation of the object</returns>
|
||||
public override string ToJson()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this.ActualInstance, _serializerSettings);
|
||||
return JsonConvert.SerializeObject(this.ActualInstance, NullableShape.SerializerSettings);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -144,19 +144,19 @@ namespace Org.OpenAPITools.Model
|
||||
/// <returns>An instance of NullableShape</returns>
|
||||
public static NullableShape FromJson(string jsonString)
|
||||
{
|
||||
NullableShape newNullableShape = new NullableShape();
|
||||
NullableShape newNullableShape = null;
|
||||
|
||||
string discriminatorValue = JObject.Parse(jsonString)["shapeType"].ToString();
|
||||
switch (discriminatorValue)
|
||||
{
|
||||
case "Quadrilateral":
|
||||
newNullableShape.ActualInstance = JsonConvert.DeserializeObject<Quadrilateral>(jsonString, newNullableShape._serializerSettings);
|
||||
newNullableShape = new NullableShape(JsonConvert.DeserializeObject<Quadrilateral>(jsonString, NullableShape.SerializerSettings));
|
||||
return newNullableShape;
|
||||
case "Triangle":
|
||||
newNullableShape.ActualInstance = JsonConvert.DeserializeObject<Triangle>(jsonString, newNullableShape._serializerSettings);
|
||||
newNullableShape = new NullableShape(JsonConvert.DeserializeObject<Triangle>(jsonString, NullableShape.SerializerSettings));
|
||||
return newNullableShape;
|
||||
default:
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to lookup discriminator value `%s` for NullableShape. Possible values: Quadrilateral Triangle", discriminatorValue));
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to lookup discriminator value `{0}` for NullableShape. Possible values: Quadrilateral Triangle", discriminatorValue));
|
||||
break;
|
||||
}
|
||||
|
||||
@ -165,26 +165,26 @@ namespace Org.OpenAPITools.Model
|
||||
|
||||
try
|
||||
{
|
||||
newNullableShape.ActualInstance = JsonConvert.DeserializeObject<Quadrilateral>(jsonString, newNullableShape._serializerSettings);
|
||||
newNullableShape = new NullableShape(JsonConvert.DeserializeObject<Quadrilateral>(jsonString, NullableShape.SerializerSettings));
|
||||
matchedTypes.Add("Quadrilateral");
|
||||
match++;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
// deserialization failed, try the next one
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `%s` into Quadrilateral: %s", jsonString, exception.ToString()));
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `{0}` into Quadrilateral: {1}", jsonString, exception.ToString()));
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
newNullableShape.ActualInstance = JsonConvert.DeserializeObject<Triangle>(jsonString, newNullableShape._serializerSettings);
|
||||
newNullableShape = new NullableShape(JsonConvert.DeserializeObject<Triangle>(jsonString, NullableShape.SerializerSettings));
|
||||
matchedTypes.Add("Triangle");
|
||||
match++;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
// deserialization failed, try the next one
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `%s` into Triangle: %s", jsonString, exception.ToString()));
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `{0}` into Triangle: {1}", jsonString, exception.ToString()));
|
||||
}
|
||||
|
||||
if (match == 0)
|
||||
|
@ -33,15 +33,6 @@ namespace Org.OpenAPITools.Model
|
||||
[DataContract(Name = "Pig")]
|
||||
public partial class Pig : AbstractOpenAPISchema, IEquatable<Pig>, IValidatableObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Pig" /> class.
|
||||
/// </summary>
|
||||
public Pig()
|
||||
{
|
||||
this.IsNullable = true;
|
||||
this.SchemaType= "oneOf";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Pig" /> class
|
||||
/// with the <see cref="BasquePig" /> class
|
||||
@ -134,7 +125,7 @@ namespace Org.OpenAPITools.Model
|
||||
/// <returns>JSON string presentation of the object</returns>
|
||||
public override string ToJson()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this.ActualInstance, _serializerSettings);
|
||||
return JsonConvert.SerializeObject(this.ActualInstance, Pig.SerializerSettings);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -144,19 +135,19 @@ namespace Org.OpenAPITools.Model
|
||||
/// <returns>An instance of Pig</returns>
|
||||
public static Pig FromJson(string jsonString)
|
||||
{
|
||||
Pig newPig = new Pig();
|
||||
Pig newPig = null;
|
||||
|
||||
string discriminatorValue = JObject.Parse(jsonString)["className"].ToString();
|
||||
switch (discriminatorValue)
|
||||
{
|
||||
case "BasquePig":
|
||||
newPig.ActualInstance = JsonConvert.DeserializeObject<BasquePig>(jsonString, newPig._serializerSettings);
|
||||
newPig = new Pig(JsonConvert.DeserializeObject<BasquePig>(jsonString, Pig.SerializerSettings));
|
||||
return newPig;
|
||||
case "DanishPig":
|
||||
newPig.ActualInstance = JsonConvert.DeserializeObject<DanishPig>(jsonString, newPig._serializerSettings);
|
||||
newPig = new Pig(JsonConvert.DeserializeObject<DanishPig>(jsonString, Pig.SerializerSettings));
|
||||
return newPig;
|
||||
default:
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to lookup discriminator value `%s` for Pig. Possible values: BasquePig DanishPig", discriminatorValue));
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to lookup discriminator value `{0}` for Pig. Possible values: BasquePig DanishPig", discriminatorValue));
|
||||
break;
|
||||
}
|
||||
|
||||
@ -165,26 +156,26 @@ namespace Org.OpenAPITools.Model
|
||||
|
||||
try
|
||||
{
|
||||
newPig.ActualInstance = JsonConvert.DeserializeObject<BasquePig>(jsonString, newPig._serializerSettings);
|
||||
newPig = new Pig(JsonConvert.DeserializeObject<BasquePig>(jsonString, Pig.SerializerSettings));
|
||||
matchedTypes.Add("BasquePig");
|
||||
match++;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
// deserialization failed, try the next one
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `%s` into BasquePig: %s", jsonString, exception.ToString()));
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `{0}` into BasquePig: {1}", jsonString, exception.ToString()));
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
newPig.ActualInstance = JsonConvert.DeserializeObject<DanishPig>(jsonString, newPig._serializerSettings);
|
||||
newPig = new Pig(JsonConvert.DeserializeObject<DanishPig>(jsonString, Pig.SerializerSettings));
|
||||
matchedTypes.Add("DanishPig");
|
||||
match++;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
// deserialization failed, try the next one
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `%s` into DanishPig: %s", jsonString, exception.ToString()));
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `{0}` into DanishPig: {1}", jsonString, exception.ToString()));
|
||||
}
|
||||
|
||||
if (match == 0)
|
||||
|
@ -33,15 +33,6 @@ namespace Org.OpenAPITools.Model
|
||||
[DataContract(Name = "Quadrilateral")]
|
||||
public partial class Quadrilateral : AbstractOpenAPISchema, IEquatable<Quadrilateral>, IValidatableObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Quadrilateral" /> class.
|
||||
/// </summary>
|
||||
public Quadrilateral()
|
||||
{
|
||||
this.IsNullable = true;
|
||||
this.SchemaType= "oneOf";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Quadrilateral" /> class
|
||||
/// with the <see cref="ComplexQuadrilateral" /> class
|
||||
@ -134,7 +125,7 @@ namespace Org.OpenAPITools.Model
|
||||
/// <returns>JSON string presentation of the object</returns>
|
||||
public override string ToJson()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this.ActualInstance, _serializerSettings);
|
||||
return JsonConvert.SerializeObject(this.ActualInstance, Quadrilateral.SerializerSettings);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -144,19 +135,19 @@ namespace Org.OpenAPITools.Model
|
||||
/// <returns>An instance of Quadrilateral</returns>
|
||||
public static Quadrilateral FromJson(string jsonString)
|
||||
{
|
||||
Quadrilateral newQuadrilateral = new Quadrilateral();
|
||||
Quadrilateral newQuadrilateral = null;
|
||||
|
||||
string discriminatorValue = JObject.Parse(jsonString)["quadrilateralType"].ToString();
|
||||
switch (discriminatorValue)
|
||||
{
|
||||
case "ComplexQuadrilateral":
|
||||
newQuadrilateral.ActualInstance = JsonConvert.DeserializeObject<ComplexQuadrilateral>(jsonString, newQuadrilateral._serializerSettings);
|
||||
newQuadrilateral = new Quadrilateral(JsonConvert.DeserializeObject<ComplexQuadrilateral>(jsonString, Quadrilateral.SerializerSettings));
|
||||
return newQuadrilateral;
|
||||
case "SimpleQuadrilateral":
|
||||
newQuadrilateral.ActualInstance = JsonConvert.DeserializeObject<SimpleQuadrilateral>(jsonString, newQuadrilateral._serializerSettings);
|
||||
newQuadrilateral = new Quadrilateral(JsonConvert.DeserializeObject<SimpleQuadrilateral>(jsonString, Quadrilateral.SerializerSettings));
|
||||
return newQuadrilateral;
|
||||
default:
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to lookup discriminator value `%s` for Quadrilateral. Possible values: ComplexQuadrilateral SimpleQuadrilateral", discriminatorValue));
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to lookup discriminator value `{0}` for Quadrilateral. Possible values: ComplexQuadrilateral SimpleQuadrilateral", discriminatorValue));
|
||||
break;
|
||||
}
|
||||
|
||||
@ -165,26 +156,26 @@ namespace Org.OpenAPITools.Model
|
||||
|
||||
try
|
||||
{
|
||||
newQuadrilateral.ActualInstance = JsonConvert.DeserializeObject<ComplexQuadrilateral>(jsonString, newQuadrilateral._serializerSettings);
|
||||
newQuadrilateral = new Quadrilateral(JsonConvert.DeserializeObject<ComplexQuadrilateral>(jsonString, Quadrilateral.SerializerSettings));
|
||||
matchedTypes.Add("ComplexQuadrilateral");
|
||||
match++;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
// deserialization failed, try the next one
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `%s` into ComplexQuadrilateral: %s", jsonString, exception.ToString()));
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `{0}` into ComplexQuadrilateral: {1}", jsonString, exception.ToString()));
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
newQuadrilateral.ActualInstance = JsonConvert.DeserializeObject<SimpleQuadrilateral>(jsonString, newQuadrilateral._serializerSettings);
|
||||
newQuadrilateral = new Quadrilateral(JsonConvert.DeserializeObject<SimpleQuadrilateral>(jsonString, Quadrilateral.SerializerSettings));
|
||||
matchedTypes.Add("SimpleQuadrilateral");
|
||||
match++;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
// deserialization failed, try the next one
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `%s` into SimpleQuadrilateral: %s", jsonString, exception.ToString()));
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `{0}` into SimpleQuadrilateral: {1}", jsonString, exception.ToString()));
|
||||
}
|
||||
|
||||
if (match == 0)
|
||||
|
@ -33,15 +33,6 @@ namespace Org.OpenAPITools.Model
|
||||
[DataContract(Name = "Shape")]
|
||||
public partial class Shape : AbstractOpenAPISchema, IEquatable<Shape>, IValidatableObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Shape" /> class.
|
||||
/// </summary>
|
||||
public Shape()
|
||||
{
|
||||
this.IsNullable = true;
|
||||
this.SchemaType= "oneOf";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Shape" /> class
|
||||
/// with the <see cref="Quadrilateral" /> class
|
||||
@ -134,7 +125,7 @@ namespace Org.OpenAPITools.Model
|
||||
/// <returns>JSON string presentation of the object</returns>
|
||||
public override string ToJson()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this.ActualInstance, _serializerSettings);
|
||||
return JsonConvert.SerializeObject(this.ActualInstance, Shape.SerializerSettings);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -144,19 +135,19 @@ namespace Org.OpenAPITools.Model
|
||||
/// <returns>An instance of Shape</returns>
|
||||
public static Shape FromJson(string jsonString)
|
||||
{
|
||||
Shape newShape = new Shape();
|
||||
Shape newShape = null;
|
||||
|
||||
string discriminatorValue = JObject.Parse(jsonString)["shapeType"].ToString();
|
||||
switch (discriminatorValue)
|
||||
{
|
||||
case "Quadrilateral":
|
||||
newShape.ActualInstance = JsonConvert.DeserializeObject<Quadrilateral>(jsonString, newShape._serializerSettings);
|
||||
newShape = new Shape(JsonConvert.DeserializeObject<Quadrilateral>(jsonString, Shape.SerializerSettings));
|
||||
return newShape;
|
||||
case "Triangle":
|
||||
newShape.ActualInstance = JsonConvert.DeserializeObject<Triangle>(jsonString, newShape._serializerSettings);
|
||||
newShape = new Shape(JsonConvert.DeserializeObject<Triangle>(jsonString, Shape.SerializerSettings));
|
||||
return newShape;
|
||||
default:
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to lookup discriminator value `%s` for Shape. Possible values: Quadrilateral Triangle", discriminatorValue));
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to lookup discriminator value `{0}` for Shape. Possible values: Quadrilateral Triangle", discriminatorValue));
|
||||
break;
|
||||
}
|
||||
|
||||
@ -165,26 +156,26 @@ namespace Org.OpenAPITools.Model
|
||||
|
||||
try
|
||||
{
|
||||
newShape.ActualInstance = JsonConvert.DeserializeObject<Quadrilateral>(jsonString, newShape._serializerSettings);
|
||||
newShape = new Shape(JsonConvert.DeserializeObject<Quadrilateral>(jsonString, Shape.SerializerSettings));
|
||||
matchedTypes.Add("Quadrilateral");
|
||||
match++;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
// deserialization failed, try the next one
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `%s` into Quadrilateral: %s", jsonString, exception.ToString()));
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `{0}` into Quadrilateral: {1}", jsonString, exception.ToString()));
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
newShape.ActualInstance = JsonConvert.DeserializeObject<Triangle>(jsonString, newShape._serializerSettings);
|
||||
newShape = new Shape(JsonConvert.DeserializeObject<Triangle>(jsonString, Shape.SerializerSettings));
|
||||
matchedTypes.Add("Triangle");
|
||||
match++;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
// deserialization failed, try the next one
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `%s` into Triangle: %s", jsonString, exception.ToString()));
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `{0}` into Triangle: {1}", jsonString, exception.ToString()));
|
||||
}
|
||||
|
||||
if (match == 0)
|
||||
|
@ -134,7 +134,7 @@ namespace Org.OpenAPITools.Model
|
||||
/// <returns>JSON string presentation of the object</returns>
|
||||
public override string ToJson()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this.ActualInstance, _serializerSettings);
|
||||
return JsonConvert.SerializeObject(this.ActualInstance, ShapeOrNull.SerializerSettings);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -144,19 +144,19 @@ namespace Org.OpenAPITools.Model
|
||||
/// <returns>An instance of ShapeOrNull</returns>
|
||||
public static ShapeOrNull FromJson(string jsonString)
|
||||
{
|
||||
ShapeOrNull newShapeOrNull = new ShapeOrNull();
|
||||
ShapeOrNull newShapeOrNull = null;
|
||||
|
||||
string discriminatorValue = JObject.Parse(jsonString)["shapeType"].ToString();
|
||||
switch (discriminatorValue)
|
||||
{
|
||||
case "Quadrilateral":
|
||||
newShapeOrNull.ActualInstance = JsonConvert.DeserializeObject<Quadrilateral>(jsonString, newShapeOrNull._serializerSettings);
|
||||
newShapeOrNull = new ShapeOrNull(JsonConvert.DeserializeObject<Quadrilateral>(jsonString, ShapeOrNull.SerializerSettings));
|
||||
return newShapeOrNull;
|
||||
case "Triangle":
|
||||
newShapeOrNull.ActualInstance = JsonConvert.DeserializeObject<Triangle>(jsonString, newShapeOrNull._serializerSettings);
|
||||
newShapeOrNull = new ShapeOrNull(JsonConvert.DeserializeObject<Triangle>(jsonString, ShapeOrNull.SerializerSettings));
|
||||
return newShapeOrNull;
|
||||
default:
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to lookup discriminator value `%s` for ShapeOrNull. Possible values: Quadrilateral Triangle", discriminatorValue));
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to lookup discriminator value `{0}` for ShapeOrNull. Possible values: Quadrilateral Triangle", discriminatorValue));
|
||||
break;
|
||||
}
|
||||
|
||||
@ -165,26 +165,26 @@ namespace Org.OpenAPITools.Model
|
||||
|
||||
try
|
||||
{
|
||||
newShapeOrNull.ActualInstance = JsonConvert.DeserializeObject<Quadrilateral>(jsonString, newShapeOrNull._serializerSettings);
|
||||
newShapeOrNull = new ShapeOrNull(JsonConvert.DeserializeObject<Quadrilateral>(jsonString, ShapeOrNull.SerializerSettings));
|
||||
matchedTypes.Add("Quadrilateral");
|
||||
match++;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
// deserialization failed, try the next one
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `%s` into Quadrilateral: %s", jsonString, exception.ToString()));
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `{0}` into Quadrilateral: {1}", jsonString, exception.ToString()));
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
newShapeOrNull.ActualInstance = JsonConvert.DeserializeObject<Triangle>(jsonString, newShapeOrNull._serializerSettings);
|
||||
newShapeOrNull = new ShapeOrNull(JsonConvert.DeserializeObject<Triangle>(jsonString, ShapeOrNull.SerializerSettings));
|
||||
matchedTypes.Add("Triangle");
|
||||
match++;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
// deserialization failed, try the next one
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `%s` into Triangle: %s", jsonString, exception.ToString()));
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `{0}` into Triangle: {1}", jsonString, exception.ToString()));
|
||||
}
|
||||
|
||||
if (match == 0)
|
||||
|
@ -33,15 +33,6 @@ namespace Org.OpenAPITools.Model
|
||||
[DataContract(Name = "Triangle")]
|
||||
public partial class Triangle : AbstractOpenAPISchema, IEquatable<Triangle>, IValidatableObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Triangle" /> class.
|
||||
/// </summary>
|
||||
public Triangle()
|
||||
{
|
||||
this.IsNullable = true;
|
||||
this.SchemaType= "oneOf";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Triangle" /> class
|
||||
/// with the <see cref="EquilateralTriangle" /> class
|
||||
@ -160,7 +151,7 @@ namespace Org.OpenAPITools.Model
|
||||
/// <returns>JSON string presentation of the object</returns>
|
||||
public override string ToJson()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this.ActualInstance, _serializerSettings);
|
||||
return JsonConvert.SerializeObject(this.ActualInstance, Triangle.SerializerSettings);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -170,22 +161,22 @@ namespace Org.OpenAPITools.Model
|
||||
/// <returns>An instance of Triangle</returns>
|
||||
public static Triangle FromJson(string jsonString)
|
||||
{
|
||||
Triangle newTriangle = new Triangle();
|
||||
Triangle newTriangle = null;
|
||||
|
||||
string discriminatorValue = JObject.Parse(jsonString)["triangleType"].ToString();
|
||||
switch (discriminatorValue)
|
||||
{
|
||||
case "EquilateralTriangle":
|
||||
newTriangle.ActualInstance = JsonConvert.DeserializeObject<EquilateralTriangle>(jsonString, newTriangle._serializerSettings);
|
||||
newTriangle = new Triangle(JsonConvert.DeserializeObject<EquilateralTriangle>(jsonString, Triangle.SerializerSettings));
|
||||
return newTriangle;
|
||||
case "IsoscelesTriangle":
|
||||
newTriangle.ActualInstance = JsonConvert.DeserializeObject<IsoscelesTriangle>(jsonString, newTriangle._serializerSettings);
|
||||
newTriangle = new Triangle(JsonConvert.DeserializeObject<IsoscelesTriangle>(jsonString, Triangle.SerializerSettings));
|
||||
return newTriangle;
|
||||
case "ScaleneTriangle":
|
||||
newTriangle.ActualInstance = JsonConvert.DeserializeObject<ScaleneTriangle>(jsonString, newTriangle._serializerSettings);
|
||||
newTriangle = new Triangle(JsonConvert.DeserializeObject<ScaleneTriangle>(jsonString, Triangle.SerializerSettings));
|
||||
return newTriangle;
|
||||
default:
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to lookup discriminator value `%s` for Triangle. Possible values: EquilateralTriangle IsoscelesTriangle ScaleneTriangle", discriminatorValue));
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to lookup discriminator value `{0}` for Triangle. Possible values: EquilateralTriangle IsoscelesTriangle ScaleneTriangle", discriminatorValue));
|
||||
break;
|
||||
}
|
||||
|
||||
@ -194,38 +185,38 @@ namespace Org.OpenAPITools.Model
|
||||
|
||||
try
|
||||
{
|
||||
newTriangle.ActualInstance = JsonConvert.DeserializeObject<EquilateralTriangle>(jsonString, newTriangle._serializerSettings);
|
||||
newTriangle = new Triangle(JsonConvert.DeserializeObject<EquilateralTriangle>(jsonString, Triangle.SerializerSettings));
|
||||
matchedTypes.Add("EquilateralTriangle");
|
||||
match++;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
// deserialization failed, try the next one
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `%s` into EquilateralTriangle: %s", jsonString, exception.ToString()));
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `{0}` into EquilateralTriangle: {1}", jsonString, exception.ToString()));
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
newTriangle.ActualInstance = JsonConvert.DeserializeObject<IsoscelesTriangle>(jsonString, newTriangle._serializerSettings);
|
||||
newTriangle = new Triangle(JsonConvert.DeserializeObject<IsoscelesTriangle>(jsonString, Triangle.SerializerSettings));
|
||||
matchedTypes.Add("IsoscelesTriangle");
|
||||
match++;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
// deserialization failed, try the next one
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `%s` into IsoscelesTriangle: %s", jsonString, exception.ToString()));
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `{0}` into IsoscelesTriangle: {1}", jsonString, exception.ToString()));
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
newTriangle.ActualInstance = JsonConvert.DeserializeObject<ScaleneTriangle>(jsonString, newTriangle._serializerSettings);
|
||||
newTriangle = new Triangle(JsonConvert.DeserializeObject<ScaleneTriangle>(jsonString, Triangle.SerializerSettings));
|
||||
matchedTypes.Add("ScaleneTriangle");
|
||||
match++;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
// deserialization failed, try the next one
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `%s` into ScaleneTriangle: %s", jsonString, exception.ToString()));
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `{0}` into ScaleneTriangle: {1}", jsonString, exception.ToString()));
|
||||
}
|
||||
|
||||
if (match == 0)
|
||||
|
@ -22,7 +22,7 @@ namespace Org.OpenAPITools.Model
|
||||
/// <summary>
|
||||
/// Custom JSON serializer
|
||||
/// </summary>
|
||||
protected readonly JsonSerializerSettings _serializerSettings = new JsonSerializerSettings
|
||||
static public readonly JsonSerializerSettings SerializerSettings = new JsonSerializerSettings
|
||||
{
|
||||
// OpenAPI generated types generally hide default constructors.
|
||||
ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor,
|
||||
|
@ -32,15 +32,6 @@ namespace Org.OpenAPITools.Model
|
||||
[DataContract(Name = "fruit")]
|
||||
public partial class Fruit : AbstractOpenAPISchema, IEquatable<Fruit>, IValidatableObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Fruit" /> class.
|
||||
/// </summary>
|
||||
public Fruit()
|
||||
{
|
||||
this.IsNullable = true;
|
||||
this.SchemaType= "oneOf";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Fruit" /> class
|
||||
/// with the <see cref="Apple" /> class
|
||||
@ -133,7 +124,7 @@ namespace Org.OpenAPITools.Model
|
||||
/// <returns>JSON string presentation of the object</returns>
|
||||
public override string ToJson()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this.ActualInstance, _serializerSettings);
|
||||
return JsonConvert.SerializeObject(this.ActualInstance, Fruit.SerializerSettings);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -143,32 +134,32 @@ namespace Org.OpenAPITools.Model
|
||||
/// <returns>An instance of Fruit</returns>
|
||||
public static Fruit FromJson(string jsonString)
|
||||
{
|
||||
Fruit newFruit = new Fruit();
|
||||
Fruit newFruit = null;
|
||||
int match = 0;
|
||||
List<string> matchedTypes = new List<string>();
|
||||
|
||||
try
|
||||
{
|
||||
newFruit.ActualInstance = JsonConvert.DeserializeObject<Apple>(jsonString, newFruit._serializerSettings);
|
||||
newFruit = new Fruit(JsonConvert.DeserializeObject<Apple>(jsonString, Fruit.SerializerSettings));
|
||||
matchedTypes.Add("Apple");
|
||||
match++;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
// deserialization failed, try the next one
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `%s` into Apple: %s", jsonString, exception.ToString()));
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `{0}` into Apple: {1}", jsonString, exception.ToString()));
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
newFruit.ActualInstance = JsonConvert.DeserializeObject<Banana>(jsonString, newFruit._serializerSettings);
|
||||
newFruit = new Fruit(JsonConvert.DeserializeObject<Banana>(jsonString, Fruit.SerializerSettings));
|
||||
matchedTypes.Add("Banana");
|
||||
match++;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
// deserialization failed, try the next one
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `%s` into Banana: %s", jsonString, exception.ToString()));
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `{0}` into Banana: {1}", jsonString, exception.ToString()));
|
||||
}
|
||||
|
||||
if (match == 0)
|
||||
|
@ -133,7 +133,7 @@ namespace Org.OpenAPITools.Model
|
||||
/// <returns>JSON string presentation of the object</returns>
|
||||
public override string ToJson()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this.ActualInstance, _serializerSettings);
|
||||
return JsonConvert.SerializeObject(this.ActualInstance, FruitReq.SerializerSettings);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -143,32 +143,32 @@ namespace Org.OpenAPITools.Model
|
||||
/// <returns>An instance of FruitReq</returns>
|
||||
public static FruitReq FromJson(string jsonString)
|
||||
{
|
||||
FruitReq newFruitReq = new FruitReq();
|
||||
FruitReq newFruitReq = null;
|
||||
int match = 0;
|
||||
List<string> matchedTypes = new List<string>();
|
||||
|
||||
try
|
||||
{
|
||||
newFruitReq.ActualInstance = JsonConvert.DeserializeObject<AppleReq>(jsonString, newFruitReq._serializerSettings);
|
||||
newFruitReq = new FruitReq(JsonConvert.DeserializeObject<AppleReq>(jsonString, FruitReq.SerializerSettings));
|
||||
matchedTypes.Add("AppleReq");
|
||||
match++;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
// deserialization failed, try the next one
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `%s` into AppleReq: %s", jsonString, exception.ToString()));
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `{0}` into AppleReq: {1}", jsonString, exception.ToString()));
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
newFruitReq.ActualInstance = JsonConvert.DeserializeObject<BananaReq>(jsonString, newFruitReq._serializerSettings);
|
||||
newFruitReq = new FruitReq(JsonConvert.DeserializeObject<BananaReq>(jsonString, FruitReq.SerializerSettings));
|
||||
matchedTypes.Add("BananaReq");
|
||||
match++;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
// deserialization failed, try the next one
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `%s` into BananaReq: %s", jsonString, exception.ToString()));
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `{0}` into BananaReq: {1}", jsonString, exception.ToString()));
|
||||
}
|
||||
|
||||
if (match == 0)
|
||||
|
@ -33,15 +33,6 @@ namespace Org.OpenAPITools.Model
|
||||
[DataContract(Name = "mammal")]
|
||||
public partial class Mammal : AbstractOpenAPISchema, IEquatable<Mammal>, IValidatableObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Mammal" /> class.
|
||||
/// </summary>
|
||||
public Mammal()
|
||||
{
|
||||
this.IsNullable = true;
|
||||
this.SchemaType= "oneOf";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Mammal" /> class
|
||||
/// with the <see cref="Pig" /> class
|
||||
@ -160,7 +151,7 @@ namespace Org.OpenAPITools.Model
|
||||
/// <returns>JSON string presentation of the object</returns>
|
||||
public override string ToJson()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this.ActualInstance, _serializerSettings);
|
||||
return JsonConvert.SerializeObject(this.ActualInstance, Mammal.SerializerSettings);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -170,44 +161,44 @@ namespace Org.OpenAPITools.Model
|
||||
/// <returns>An instance of Mammal</returns>
|
||||
public static Mammal FromJson(string jsonString)
|
||||
{
|
||||
Mammal newMammal = new Mammal();
|
||||
Mammal newMammal = null;
|
||||
int match = 0;
|
||||
List<string> matchedTypes = new List<string>();
|
||||
|
||||
try
|
||||
{
|
||||
newMammal.ActualInstance = JsonConvert.DeserializeObject<Pig>(jsonString, newMammal._serializerSettings);
|
||||
newMammal = new Mammal(JsonConvert.DeserializeObject<Pig>(jsonString, Mammal.SerializerSettings));
|
||||
matchedTypes.Add("Pig");
|
||||
match++;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
// deserialization failed, try the next one
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `%s` into Pig: %s", jsonString, exception.ToString()));
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `{0}` into Pig: {1}", jsonString, exception.ToString()));
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
newMammal.ActualInstance = JsonConvert.DeserializeObject<Whale>(jsonString, newMammal._serializerSettings);
|
||||
newMammal = new Mammal(JsonConvert.DeserializeObject<Whale>(jsonString, Mammal.SerializerSettings));
|
||||
matchedTypes.Add("Whale");
|
||||
match++;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
// deserialization failed, try the next one
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `%s` into Whale: %s", jsonString, exception.ToString()));
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `{0}` into Whale: {1}", jsonString, exception.ToString()));
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
newMammal.ActualInstance = JsonConvert.DeserializeObject<Zebra>(jsonString, newMammal._serializerSettings);
|
||||
newMammal = new Mammal(JsonConvert.DeserializeObject<Zebra>(jsonString, Mammal.SerializerSettings));
|
||||
matchedTypes.Add("Zebra");
|
||||
match++;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
// deserialization failed, try the next one
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `%s` into Zebra: %s", jsonString, exception.ToString()));
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `{0}` into Zebra: {1}", jsonString, exception.ToString()));
|
||||
}
|
||||
|
||||
if (match == 0)
|
||||
|
@ -134,7 +134,7 @@ namespace Org.OpenAPITools.Model
|
||||
/// <returns>JSON string presentation of the object</returns>
|
||||
public override string ToJson()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this.ActualInstance, _serializerSettings);
|
||||
return JsonConvert.SerializeObject(this.ActualInstance, NullableShape.SerializerSettings);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -144,32 +144,32 @@ namespace Org.OpenAPITools.Model
|
||||
/// <returns>An instance of NullableShape</returns>
|
||||
public static NullableShape FromJson(string jsonString)
|
||||
{
|
||||
NullableShape newNullableShape = new NullableShape();
|
||||
NullableShape newNullableShape = null;
|
||||
int match = 0;
|
||||
List<string> matchedTypes = new List<string>();
|
||||
|
||||
try
|
||||
{
|
||||
newNullableShape.ActualInstance = JsonConvert.DeserializeObject<Quadrilateral>(jsonString, newNullableShape._serializerSettings);
|
||||
newNullableShape = new NullableShape(JsonConvert.DeserializeObject<Quadrilateral>(jsonString, NullableShape.SerializerSettings));
|
||||
matchedTypes.Add("Quadrilateral");
|
||||
match++;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
// deserialization failed, try the next one
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `%s` into Quadrilateral: %s", jsonString, exception.ToString()));
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `{0}` into Quadrilateral: {1}", jsonString, exception.ToString()));
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
newNullableShape.ActualInstance = JsonConvert.DeserializeObject<Triangle>(jsonString, newNullableShape._serializerSettings);
|
||||
newNullableShape = new NullableShape(JsonConvert.DeserializeObject<Triangle>(jsonString, NullableShape.SerializerSettings));
|
||||
matchedTypes.Add("Triangle");
|
||||
match++;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
// deserialization failed, try the next one
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `%s` into Triangle: %s", jsonString, exception.ToString()));
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `{0}` into Triangle: {1}", jsonString, exception.ToString()));
|
||||
}
|
||||
|
||||
if (match == 0)
|
||||
|
@ -33,15 +33,6 @@ namespace Org.OpenAPITools.Model
|
||||
[DataContract(Name = "Pig")]
|
||||
public partial class Pig : AbstractOpenAPISchema, IEquatable<Pig>, IValidatableObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Pig" /> class.
|
||||
/// </summary>
|
||||
public Pig()
|
||||
{
|
||||
this.IsNullable = true;
|
||||
this.SchemaType= "oneOf";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Pig" /> class
|
||||
/// with the <see cref="BasquePig" /> class
|
||||
@ -134,7 +125,7 @@ namespace Org.OpenAPITools.Model
|
||||
/// <returns>JSON string presentation of the object</returns>
|
||||
public override string ToJson()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this.ActualInstance, _serializerSettings);
|
||||
return JsonConvert.SerializeObject(this.ActualInstance, Pig.SerializerSettings);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -144,32 +135,32 @@ namespace Org.OpenAPITools.Model
|
||||
/// <returns>An instance of Pig</returns>
|
||||
public static Pig FromJson(string jsonString)
|
||||
{
|
||||
Pig newPig = new Pig();
|
||||
Pig newPig = null;
|
||||
int match = 0;
|
||||
List<string> matchedTypes = new List<string>();
|
||||
|
||||
try
|
||||
{
|
||||
newPig.ActualInstance = JsonConvert.DeserializeObject<BasquePig>(jsonString, newPig._serializerSettings);
|
||||
newPig = new Pig(JsonConvert.DeserializeObject<BasquePig>(jsonString, Pig.SerializerSettings));
|
||||
matchedTypes.Add("BasquePig");
|
||||
match++;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
// deserialization failed, try the next one
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `%s` into BasquePig: %s", jsonString, exception.ToString()));
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `{0}` into BasquePig: {1}", jsonString, exception.ToString()));
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
newPig.ActualInstance = JsonConvert.DeserializeObject<DanishPig>(jsonString, newPig._serializerSettings);
|
||||
newPig = new Pig(JsonConvert.DeserializeObject<DanishPig>(jsonString, Pig.SerializerSettings));
|
||||
matchedTypes.Add("DanishPig");
|
||||
match++;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
// deserialization failed, try the next one
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `%s` into DanishPig: %s", jsonString, exception.ToString()));
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `{0}` into DanishPig: {1}", jsonString, exception.ToString()));
|
||||
}
|
||||
|
||||
if (match == 0)
|
||||
|
@ -33,15 +33,6 @@ namespace Org.OpenAPITools.Model
|
||||
[DataContract(Name = "Quadrilateral")]
|
||||
public partial class Quadrilateral : AbstractOpenAPISchema, IEquatable<Quadrilateral>, IValidatableObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Quadrilateral" /> class.
|
||||
/// </summary>
|
||||
public Quadrilateral()
|
||||
{
|
||||
this.IsNullable = true;
|
||||
this.SchemaType= "oneOf";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Quadrilateral" /> class
|
||||
/// with the <see cref="ComplexQuadrilateral" /> class
|
||||
@ -134,7 +125,7 @@ namespace Org.OpenAPITools.Model
|
||||
/// <returns>JSON string presentation of the object</returns>
|
||||
public override string ToJson()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this.ActualInstance, _serializerSettings);
|
||||
return JsonConvert.SerializeObject(this.ActualInstance, Quadrilateral.SerializerSettings);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -144,32 +135,32 @@ namespace Org.OpenAPITools.Model
|
||||
/// <returns>An instance of Quadrilateral</returns>
|
||||
public static Quadrilateral FromJson(string jsonString)
|
||||
{
|
||||
Quadrilateral newQuadrilateral = new Quadrilateral();
|
||||
Quadrilateral newQuadrilateral = null;
|
||||
int match = 0;
|
||||
List<string> matchedTypes = new List<string>();
|
||||
|
||||
try
|
||||
{
|
||||
newQuadrilateral.ActualInstance = JsonConvert.DeserializeObject<ComplexQuadrilateral>(jsonString, newQuadrilateral._serializerSettings);
|
||||
newQuadrilateral = new Quadrilateral(JsonConvert.DeserializeObject<ComplexQuadrilateral>(jsonString, Quadrilateral.SerializerSettings));
|
||||
matchedTypes.Add("ComplexQuadrilateral");
|
||||
match++;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
// deserialization failed, try the next one
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `%s` into ComplexQuadrilateral: %s", jsonString, exception.ToString()));
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `{0}` into ComplexQuadrilateral: {1}", jsonString, exception.ToString()));
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
newQuadrilateral.ActualInstance = JsonConvert.DeserializeObject<SimpleQuadrilateral>(jsonString, newQuadrilateral._serializerSettings);
|
||||
newQuadrilateral = new Quadrilateral(JsonConvert.DeserializeObject<SimpleQuadrilateral>(jsonString, Quadrilateral.SerializerSettings));
|
||||
matchedTypes.Add("SimpleQuadrilateral");
|
||||
match++;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
// deserialization failed, try the next one
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `%s` into SimpleQuadrilateral: %s", jsonString, exception.ToString()));
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `{0}` into SimpleQuadrilateral: {1}", jsonString, exception.ToString()));
|
||||
}
|
||||
|
||||
if (match == 0)
|
||||
|
@ -33,15 +33,6 @@ namespace Org.OpenAPITools.Model
|
||||
[DataContract(Name = "Shape")]
|
||||
public partial class Shape : AbstractOpenAPISchema, IEquatable<Shape>, IValidatableObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Shape" /> class.
|
||||
/// </summary>
|
||||
public Shape()
|
||||
{
|
||||
this.IsNullable = true;
|
||||
this.SchemaType= "oneOf";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Shape" /> class
|
||||
/// with the <see cref="Quadrilateral" /> class
|
||||
@ -134,7 +125,7 @@ namespace Org.OpenAPITools.Model
|
||||
/// <returns>JSON string presentation of the object</returns>
|
||||
public override string ToJson()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this.ActualInstance, _serializerSettings);
|
||||
return JsonConvert.SerializeObject(this.ActualInstance, Shape.SerializerSettings);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -144,32 +135,32 @@ namespace Org.OpenAPITools.Model
|
||||
/// <returns>An instance of Shape</returns>
|
||||
public static Shape FromJson(string jsonString)
|
||||
{
|
||||
Shape newShape = new Shape();
|
||||
Shape newShape = null;
|
||||
int match = 0;
|
||||
List<string> matchedTypes = new List<string>();
|
||||
|
||||
try
|
||||
{
|
||||
newShape.ActualInstance = JsonConvert.DeserializeObject<Quadrilateral>(jsonString, newShape._serializerSettings);
|
||||
newShape = new Shape(JsonConvert.DeserializeObject<Quadrilateral>(jsonString, Shape.SerializerSettings));
|
||||
matchedTypes.Add("Quadrilateral");
|
||||
match++;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
// deserialization failed, try the next one
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `%s` into Quadrilateral: %s", jsonString, exception.ToString()));
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `{0}` into Quadrilateral: {1}", jsonString, exception.ToString()));
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
newShape.ActualInstance = JsonConvert.DeserializeObject<Triangle>(jsonString, newShape._serializerSettings);
|
||||
newShape = new Shape(JsonConvert.DeserializeObject<Triangle>(jsonString, Shape.SerializerSettings));
|
||||
matchedTypes.Add("Triangle");
|
||||
match++;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
// deserialization failed, try the next one
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `%s` into Triangle: %s", jsonString, exception.ToString()));
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `{0}` into Triangle: {1}", jsonString, exception.ToString()));
|
||||
}
|
||||
|
||||
if (match == 0)
|
||||
|
@ -134,7 +134,7 @@ namespace Org.OpenAPITools.Model
|
||||
/// <returns>JSON string presentation of the object</returns>
|
||||
public override string ToJson()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this.ActualInstance, _serializerSettings);
|
||||
return JsonConvert.SerializeObject(this.ActualInstance, ShapeOrNull.SerializerSettings);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -144,32 +144,32 @@ namespace Org.OpenAPITools.Model
|
||||
/// <returns>An instance of ShapeOrNull</returns>
|
||||
public static ShapeOrNull FromJson(string jsonString)
|
||||
{
|
||||
ShapeOrNull newShapeOrNull = new ShapeOrNull();
|
||||
ShapeOrNull newShapeOrNull = null;
|
||||
int match = 0;
|
||||
List<string> matchedTypes = new List<string>();
|
||||
|
||||
try
|
||||
{
|
||||
newShapeOrNull.ActualInstance = JsonConvert.DeserializeObject<Quadrilateral>(jsonString, newShapeOrNull._serializerSettings);
|
||||
newShapeOrNull = new ShapeOrNull(JsonConvert.DeserializeObject<Quadrilateral>(jsonString, ShapeOrNull.SerializerSettings));
|
||||
matchedTypes.Add("Quadrilateral");
|
||||
match++;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
// deserialization failed, try the next one
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `%s` into Quadrilateral: %s", jsonString, exception.ToString()));
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `{0}` into Quadrilateral: {1}", jsonString, exception.ToString()));
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
newShapeOrNull.ActualInstance = JsonConvert.DeserializeObject<Triangle>(jsonString, newShapeOrNull._serializerSettings);
|
||||
newShapeOrNull = new ShapeOrNull(JsonConvert.DeserializeObject<Triangle>(jsonString, ShapeOrNull.SerializerSettings));
|
||||
matchedTypes.Add("Triangle");
|
||||
match++;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
// deserialization failed, try the next one
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `%s` into Triangle: %s", jsonString, exception.ToString()));
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `{0}` into Triangle: {1}", jsonString, exception.ToString()));
|
||||
}
|
||||
|
||||
if (match == 0)
|
||||
|
@ -33,15 +33,6 @@ namespace Org.OpenAPITools.Model
|
||||
[DataContract(Name = "Triangle")]
|
||||
public partial class Triangle : AbstractOpenAPISchema, IEquatable<Triangle>, IValidatableObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Triangle" /> class.
|
||||
/// </summary>
|
||||
public Triangle()
|
||||
{
|
||||
this.IsNullable = true;
|
||||
this.SchemaType= "oneOf";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Triangle" /> class
|
||||
/// with the <see cref="EquilateralTriangle" /> class
|
||||
@ -160,7 +151,7 @@ namespace Org.OpenAPITools.Model
|
||||
/// <returns>JSON string presentation of the object</returns>
|
||||
public override string ToJson()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this.ActualInstance, _serializerSettings);
|
||||
return JsonConvert.SerializeObject(this.ActualInstance, Triangle.SerializerSettings);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -170,44 +161,44 @@ namespace Org.OpenAPITools.Model
|
||||
/// <returns>An instance of Triangle</returns>
|
||||
public static Triangle FromJson(string jsonString)
|
||||
{
|
||||
Triangle newTriangle = new Triangle();
|
||||
Triangle newTriangle = null;
|
||||
int match = 0;
|
||||
List<string> matchedTypes = new List<string>();
|
||||
|
||||
try
|
||||
{
|
||||
newTriangle.ActualInstance = JsonConvert.DeserializeObject<EquilateralTriangle>(jsonString, newTriangle._serializerSettings);
|
||||
newTriangle = new Triangle(JsonConvert.DeserializeObject<EquilateralTriangle>(jsonString, Triangle.SerializerSettings));
|
||||
matchedTypes.Add("EquilateralTriangle");
|
||||
match++;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
// deserialization failed, try the next one
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `%s` into EquilateralTriangle: %s", jsonString, exception.ToString()));
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `{0}` into EquilateralTriangle: {1}", jsonString, exception.ToString()));
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
newTriangle.ActualInstance = JsonConvert.DeserializeObject<IsoscelesTriangle>(jsonString, newTriangle._serializerSettings);
|
||||
newTriangle = new Triangle(JsonConvert.DeserializeObject<IsoscelesTriangle>(jsonString, Triangle.SerializerSettings));
|
||||
matchedTypes.Add("IsoscelesTriangle");
|
||||
match++;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
// deserialization failed, try the next one
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `%s` into IsoscelesTriangle: %s", jsonString, exception.ToString()));
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `{0}` into IsoscelesTriangle: {1}", jsonString, exception.ToString()));
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
newTriangle.ActualInstance = JsonConvert.DeserializeObject<ScaleneTriangle>(jsonString, newTriangle._serializerSettings);
|
||||
newTriangle = new Triangle(JsonConvert.DeserializeObject<ScaleneTriangle>(jsonString, Triangle.SerializerSettings));
|
||||
matchedTypes.Add("ScaleneTriangle");
|
||||
match++;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
// deserialization failed, try the next one
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `%s` into ScaleneTriangle: %s", jsonString, exception.ToString()));
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to deserialize `{0}` into ScaleneTriangle: {1}", jsonString, exception.ToString()));
|
||||
}
|
||||
|
||||
if (match == 0)
|
||||
|
Loading…
x
Reference in New Issue
Block a user