Exemplo n.º 1
0
        public async Task <TApiQueryResult> Query <TApiQueryResult>(IApiQuery <TApiQueryResult> query)
        {
            using (var webClient = new System.Net.WebClient())
            {
                webClient.QueryString = query.Parameters.Aggregate(new NameValueCollection(),
                                                                   (seed, current) => {
                    seed.Add(current.Key, current.Value);
                    return(seed);
                });
                var json = await webClient.DownloadStringTaskAsync(QUERY_URL);

                return(_deserializer.Deserialize <TApiQueryResult>(json));
            }
        }
Exemplo n.º 2
0
        public async Task <TApiQueryResult> Query <TApiQueryResult>(IApiQuery <TApiQueryResult> query)
        {
            using (var webClient = new System.Net.WebClient())
            {
                webClient.QueryString = query.Parameters.Aggregate(new NameValueCollection(),
                                                                   (seed, current) => {
                    seed.Add(current.Key, current.Value);
                    return(seed);
                });
                using (var stream = await webClient.OpenReadTaskAsync(QUERY_URL))
                {
                    var result = _deserializer.Deserialize <TApiQueryResult>(stream);

                    return(result);
                }
            }
        }