/// <summary> /// Reads the JSON representation of the object. /// </summary> /// <param name="reader">The <see cref="T:Newtonsoft.Json.JsonReader"/> to read from.</param><param name="objectType">Type of the object.</param><param name="existingValue">The existing value of object being read.</param><param name="serializer">The calling serializer.</param> /// <returns> /// The object value. /// </returns> public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { var ringArray = serializer.Deserialize(reader) as JArray; var converter = new LineStringConverter(); var rings = ringArray.Select(ring => (LineString)converter.ReadJson(reader, typeof(LineString), ring, serializer)).ToList(); return(rings); }
/// <summary> /// Reads the JSON representation of the object. /// </summary> /// <param name="reader">The <see cref="T:Newtonsoft.Json.JsonReader" /> to read from.</param> /// <param name="objectType">Type of the object.</param> /// <param name="existingValue">The existing value of object being read.</param> /// <param name="serializer">The calling serializer.</param> /// <returns> /// The object value. /// </returns> public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { var rings = serializer.Deserialize <double[][][]>(reader); var lineStrings = new List <LineString>(rings.Length); foreach (var ring in rings) { var positions = (IEnumerable <IPosition>)LineStringConverter.ReadJson(reader, typeof(LineString), ring, serializer); lineStrings.Add(new LineString(positions)); } return(lineStrings); }