/// <summary> /// 拷贝构造函数。 /// </summary> /// <param name="pointWithMeasure"></param> public PointWithMeasure(PointWithMeasure pointWithMeasure) : base(pointWithMeasure) { if (pointWithMeasure == null) throw new ArgumentException(); this.Measure = pointWithMeasure.Measure; }
public void Json_RoutePoints() { Route route = new Route(); PointWithMeasure[] points = new PointWithMeasure[2]; PointWithMeasure p1 = new PointWithMeasure(); p1.X = 1; p1.Y = 2; p1.Measure = 2.2; PointWithMeasure p2 = new PointWithMeasure(); p2.X = 1; p2.Y = 2; p2.Measure = 2.3; points[0] = p1; points[1] = p2; route.Points = points; route.Id = 1; route.Length = 3; route.Line = new Geometry(); route.MaxM = 1.3; route.MinM = 0.3; route.Parts = new int[2] { 1, 3 }; route.Region = new Geometry(); route.Style = new Style(); string strroute = Newtonsoft.Json.JsonConvert.SerializeObject(route); Route r1 = Newtonsoft.Json.JsonConvert.DeserializeObject<Route>(strroute); Assert.AreEqual(r1.Points[0].Measure, 2.2); Assert.AreEqual(r1.Points[1].Measure, 2.3); }