17 using System.Collections.Generic;
18 using Newtonsoft.Json;
19 using Newtonsoft.Json.Linq;
28 private Dictionary<string, ProductType> _productTypeMap =
new Dictionary<string, ProductType>()
30 {
"Professional Seats",
ProductType.ProfessionalSeats},
56 return objectType == typeof(
Product);
63 public override void WriteJson(JsonWriter writer,
object value, JsonSerializer serializer)
65 throw new NotImplementedException(
"The OrderJsonConverter does not implement a WriteJson method;.");
75 public override object ReadJson(JsonReader reader, Type objectType,
object existingValue, JsonSerializer serializer)
77 var jObject = JObject.Load(reader);
96 var productTypeName = jObject[
"name"].Value<
string>();
97 if (!_productTypeMap.ContainsKey(productTypeName))
104 Type = _productTypeMap[productTypeName],
105 Items = jObject[
"items"].ToObject<List<ProductItem>>()