/// <summary> /// To convert a JSON string into an object /// </summary> /// <param name="reader">JSON reader</param> /// <param name="objectType">Object type</param> /// <param name="existingValue">Existing value</param> /// <param name="serializer">JSON Serializer</param> /// <returns>The object converted from the JSON string</returns> public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { if (reader.TokenType != JsonToken.Null) { return(ShapeOrNull.FromJson(JObject.Load(reader).ToString(Formatting.None))); } return(null); }
/// <summary> /// Initializes a new instance of the <see cref="Drawing" /> class. /// </summary> /// <param name="mainShape">mainShape.</param> /// <param name="shapeOrNull">shapeOrNull.</param> /// <param name="nullableShape">nullableShape.</param> /// <param name="shapes">shapes.</param> public Drawing(Shape mainShape = default(Shape), ShapeOrNull shapeOrNull = default(ShapeOrNull), NullableShape nullableShape = default(NullableShape), List <Shape> shapes = default(List <Shape>)) : base() { this._MainShape = mainShape; if (this.MainShape != null) { this._flagMainShape = true; } this._ShapeOrNull = shapeOrNull; if (this.ShapeOrNull != null) { this._flagShapeOrNull = true; } this._NullableShape = nullableShape; if (this.NullableShape != null) { this._flagNullableShape = true; } this._Shapes = shapes; if (this.Shapes != null) { this._flagShapes = true; } }