コード例 #1
0
        private static HttpWebRequest PrepareGetRequest(PlayerClassRoute playerClassRoute)
        {
            var url     = endPath + "/classes/" + playerClassRoute.Value;
            var request = (HttpWebRequest)WebRequest.Create(url);

            request.Method    = "GET";
            request.UserAgent = url;
            request.AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip | DecompressionMethods.None;

            return(request);
        }
コード例 #2
0
        private static PlayerClassJson GetPlayerClassAsync(PlayerClassRoute playerClassRoute)
        {
            var characterClass = new PlayerClassJson();

            using (var response = (HttpWebResponse)PrepareGetRequest(playerClassRoute).GetResponse())
            {
                using (var stream = response.GetResponseStream())
                {
                    using (var sr = new StreamReader(stream))
                    {
                        characterClass = JsonConvert.DeserializeObject <PlayerClassJson>(sr.ReadToEnd());
                    }
                }
            }
            return(characterClass);
        }