public static void Read(ref Coordinate coordinate, JsonTextReader jreader) { if (coordinate == null) throw new ArgumentNullException("coordinate", "A valid coordinate reference is required."); if (jreader == null) throw new ArgumentNullException("jreader", "A valid JSON reader object is required."); if (jreader.MoveToContent() && jreader.TokenClass == JsonTokenClass.Array) { jreader.ReadToken(JsonTokenClass.Array); coordinate.X = Convert.ToDouble(jreader.ReadNumber()); coordinate.Y = Convert.ToDouble(jreader.ReadNumber()); coordinate.Z = double.NaN; if (jreader.TokenClass == JsonTokenClass.Number) coordinate.Z = Convert.ToDouble(jreader.ReadNumber()); jreader.ReadToken(JsonTokenClass.EndArray); } }
private static Point ReadPoint(JsonTextReader jreader) { if (jreader == null) throw new ArgumentNullException("reader", "A valid JSON reader object is required."); Point point = null; if (jreader.TokenClass == JsonTokenClass.Array) { jreader.ReadToken(JsonTokenClass.Array); double x = Convert.ToDouble(jreader.ReadNumber()); double y = Convert.ToDouble(jreader.ReadNumber()); double z = double.NaN; if (jreader.TokenClass == JsonTokenClass.Number) z = Convert.ToDouble(jreader.ReadNumber()); jreader.ReadToken(JsonTokenClass.EndArray); point = new Point(x, y, z); } return point; }