示例#1
0
        private MatchList GetMatchListOfSummoner(string accountId, string region, int?startIndex = null, int?endIndex = null)
        {
            var pathBuilder = new UrlPathBuilder();
            var matchList   = new MatchList();

            using (var client = new HttpClient())
            {
                try
                {
                    client.DefaultRequestHeaders.Add("X-Riot-Token", ConfigWrapper.ApiKey);
                    Task <HttpResponseMessage> response;
                    if (startIndex.HasValue && endIndex.HasValue)
                    {
                        response = client.GetAsync(new Uri(pathBuilder.GetMatchListOfSummonerByAccountIdUrl(accountId, startIndex.Value, endIndex.Value, region)));
                    }
                    else
                    {
                        response = client.GetAsync(new Uri(pathBuilder.GetMatchListOfSummonerByAccountIdUrl(accountId, region)));
                    }
                    response.Wait();

                    var result = response.Result;
                    if (result.IsSuccessStatusCode)
                    {
                        var readData = result.Content.ReadAsStringAsync();
                        readData.Wait();

                        matchList = JsonConvert.DeserializeObject <MatchList>(readData.Result);
                    }
                }
                catch (Exception) {}
            }
            return(matchList);
        }