Ejemplo n.º 1
0
        protected async Task <T> SendAsync <T>(string service, List <Tuple <string, string> > urlParams)
        {
            var fullUrl        = OsrmRequestBuilder.GetUrl(Url, service, urlParams);
            var responseString = await client.GetStringAsync(fullUrl);


            return(JsonConvert.DeserializeObject <T>(responseString));;
        }
Ejemplo n.º 2
0
        protected T Send <T>(string service, List <Tuple <string, string> > urlParams)
        {
            var    fullUrl = OsrmRequestBuilder.GetUrl(Url, service, urlParams);
            string json    = null;

            using (var client = new WebClient())
            {
                json = client.DownloadString(new Uri(fullUrl));
            }

            return(JsonConvert.DeserializeObject <T>(json));;
        }
Ejemplo n.º 3
0
        protected T Send <T>(string service, BaseRequest request) //string coordinatesStr, List<Tuple<string, string>> urlParams)
        {
            var coordinatesStr = request.CoordinatesUrlPart;
            List <Tuple <string, string> > urlParams = request.UrlParams;
            var    fullUrl = OsrmRequestBuilder.GetUrl(Url, service, Version, Profile, coordinatesStr, urlParams);
            string json    = null;

            using (var client = new OsrmWebClient(Timeout))
            {
                json = client.DownloadString(new Uri(fullUrl));
            }

            return(JsonConvert.DeserializeObject <T>(json));;
        }
Ejemplo n.º 4
0
        protected async Task <T> Send <T>(string service, BaseRequest request) //string coordinatesStr, List<Tuple<string, string>> urlParams)
        {
            var coordinatesStr = request.CoordinatesUrlPart;
            List <Tuple <string, string> > urlParams = request.UrlParams;
            var fullUrl = OsrmRequestBuilder.GetUrl(Url, service, Version, Profile, coordinatesStr, urlParams);

            try
            {
                string responseBody = await Client.GetStringAsync(fullUrl);

                return(await Task.FromResult(JsonSerializer.Deserialize <T>(responseBody)));
            }
            catch (HttpRequestException e)
            {
                Console.WriteLine("\nException Caught!");
                Console.WriteLine("Message :{0} ", e.Message);
                throw;
            }
        }