コード例 #1
0
        private static GetRouteResponse GetRouteSample(string routeID)
        {
            GetRouteRequest gr = new GetRouteRequest()
            {
                RouteId = routeID
            };

            Console.WriteLine(gr.URL);
            GetRouteResponse grr = gr.Get();

            return(grr);
        }
コード例 #2
0
        private void btnTestService_Click(object sender, EventArgs e)
        {
            RouteService.IRouteService RouteService  = new RouteServiceClient();
            RouteServiceParameterDTO   originalroute = new RouteServiceParameterDTO();

            //originalroute.StreetAvenueName = "Rua XYZ de ABC";
            originalroute.StreetAvenueName = "Rua Jose Fabiano Rodrigues";
            originalroute.Number           = "10";
            originalroute.City             = "Osasco";
            originalroute.State            = "SP";

            RouteServiceParameterDTO destinationroute = new RouteServiceParameterDTO();

            destinationroute.StreetAvenueName = "Avenida Manoel Pedro Pimentel";
            destinationroute.Number           = "155";
            destinationroute.City             = "Osasco";
            destinationroute.State            = "SP";

            GetRouteRequest inValue = new GetRouteRequest();

            inValue.Body = new GetRouteRequestBody();
            RouteServiceParameterRequestDTO routeServiceParameterRequestDTO = new RouteServiceParameterRequestDTO();

            routeServiceParameterRequestDTO.originalRoute    = originalroute;
            routeServiceParameterRequestDTO.destinationRoute = destinationroute;
            routeServiceParameterRequestDTO.routeType        = RouteType.FastestRoute;
            inValue.Body.routeParameterRequest = routeServiceParameterRequestDTO;

            try
            {
                GetRouteResponse retVal = RouteService.GetRoute(inValue);
                string           result = "Distancia Total {0}. Custo Combustivel {1}. Tempo Total Rota {2}. Custo Considerando Pedagio {3}";
                if (retVal.Body.GetRouteResult != null)
                {
                    MessageBox.Show(string.Format(result, retVal.Body.GetRouteResult.TotalDistance.ToString(),
                                                  retVal.Body.GetRouteResult.TotalFuelCost.ToString(),
                                                  retVal.Body.GetRouteResult.TotalTime.ToString(),
                                                  retVal.Body.GetRouteResult.TotalTollFeeCost.ToString()));
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
コード例 #3
0
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            GetRouteResponse response = new GetRouteResponse();

            context.Read();
            int targetDepth = context.CurrentDepth;

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("ApplicationId", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.ApplicationId = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("Arn", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.Arn = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("CreatedByAccountId", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.CreatedByAccountId = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("CreatedTime", targetDepth))
                {
                    var unmarshaller = DateTimeUnmarshaller.Instance;
                    response.CreatedTime = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("EnvironmentId", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.EnvironmentId = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("Error", targetDepth))
                {
                    var unmarshaller = ErrorResponseUnmarshaller.Instance;
                    response.Error = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("IncludeChildPaths", targetDepth))
                {
                    var unmarshaller = BoolUnmarshaller.Instance;
                    response.IncludeChildPaths = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("LastUpdatedTime", targetDepth))
                {
                    var unmarshaller = DateTimeUnmarshaller.Instance;
                    response.LastUpdatedTime = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("Methods", targetDepth))
                {
                    var unmarshaller = new ListUnmarshaller <string, StringUnmarshaller>(StringUnmarshaller.Instance);
                    response.Methods = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("OwnerAccountId", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.OwnerAccountId = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("PathResourceToId", targetDepth))
                {
                    var unmarshaller = new DictionaryUnmarshaller <string, string, StringUnmarshaller, StringUnmarshaller>(StringUnmarshaller.Instance, StringUnmarshaller.Instance);
                    response.PathResourceToId = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("RouteId", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.RouteId = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("RouteType", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.RouteType = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("ServiceId", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.ServiceId = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("SourcePath", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.SourcePath = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("State", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.State = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("Tags", targetDepth))
                {
                    var unmarshaller = new DictionaryUnmarshaller <string, string, StringUnmarshaller, StringUnmarshaller>(StringUnmarshaller.Instance, StringUnmarshaller.Instance);
                    response.Tags = unmarshaller.Unmarshall(context);
                    continue;
                }
            }

            return(response);
        }
コード例 #4
0
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            GetRouteResponse response = new GetRouteResponse();

            context.Read();
            int targetDepth = context.CurrentDepth;

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("apiGatewayManaged", targetDepth))
                {
                    var unmarshaller = BoolUnmarshaller.Instance;
                    response.ApiGatewayManaged = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("apiKeyRequired", targetDepth))
                {
                    var unmarshaller = BoolUnmarshaller.Instance;
                    response.ApiKeyRequired = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("authorizationScopes", targetDepth))
                {
                    var unmarshaller = new ListUnmarshaller <string, StringUnmarshaller>(StringUnmarshaller.Instance);
                    response.AuthorizationScopes = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("authorizationType", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.AuthorizationType = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("authorizerId", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.AuthorizerId = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("modelSelectionExpression", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.ModelSelectionExpression = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("operationName", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.OperationName = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("requestModels", targetDepth))
                {
                    var unmarshaller = new DictionaryUnmarshaller <string, string, StringUnmarshaller, StringUnmarshaller>(StringUnmarshaller.Instance, StringUnmarshaller.Instance);
                    response.RequestModels = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("requestParameters", targetDepth))
                {
                    var unmarshaller = new DictionaryUnmarshaller <string, ParameterConstraints, StringUnmarshaller, ParameterConstraintsUnmarshaller>(StringUnmarshaller.Instance, ParameterConstraintsUnmarshaller.Instance);
                    response.RequestParameters = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("routeId", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.RouteId = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("routeKey", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.RouteKey = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("routeResponseSelectionExpression", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.RouteResponseSelectionExpression = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("target", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.Target = unmarshaller.Unmarshall(context);
                    continue;
                }
            }

            return(response);
        }