/// <summary> /// Unmarshaller the response from the service to the response class. /// </summary> /// <param name="context"></param> /// <returns></returns> public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context) { CalculateRouteResponse response = new CalculateRouteResponse(); context.Read(); int targetDepth = context.CurrentDepth; while (context.ReadAtDepth(targetDepth)) { if (context.TestExpression("Legs", targetDepth)) { var unmarshaller = new ListUnmarshaller <Leg, LegUnmarshaller>(LegUnmarshaller.Instance); response.Legs = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("Summary", targetDepth)) { var unmarshaller = CalculateRouteSummaryUnmarshaller.Instance; response.Summary = unmarshaller.Unmarshall(context); continue; } } return(response); }
private static CalculateRouteResponse CalculateRouteSample() { CalculateRouteRequest cr = new CalculateRouteRequest() { RoutingMode = new RequestRoutingMode(RoutingType.Fastest, TransportModeType.Car), Waypoints = new WaypointParameter[] { new GeoWaypointParameter(0, new GeoCoordinate(51.459047, -0.4415217)), new GeoWaypointParameter(1, new GeoCoordinate(51.542026, 0.281487)) }, Departure = new DateTime(2018, 05, 15, 19, 00, 00), RouteAttributes = new RouteAttributeType[] { RouteAttributeType.Shape, RouteAttributeType.Legs, RouteAttributeType.Incidents, RouteAttributeType.Groups, RouteAttributeType.RouteId }, LegAttributes = new RouteLegAttributeType[] { RouteLegAttributeType.Links }, ManeuverAttributes = new ManeuverAttributeType[] { ManeuverAttributeType.Time, ManeuverAttributeType.TrafficTime, ManeuverAttributeType.BaseTime, ManeuverAttributeType.Notes }, InstructionFormat = InstructionFormatType.Text }; Console.WriteLine(cr.URL); CalculateRouteResponse crr = cr.Get(); return(crr); }