CreateGetRequestAsync() 공개 메소드

public CreateGetRequestAsync ( string relativeUrl, string rootDomain, List addedArguments = null, bool useHttps = true ) : Task
relativeUrl string
rootDomain string
addedArguments List
useHttps bool
리턴 Task
예제 #1
0
        /// <summary>
        /// Get the list of shards asynchronously.
        /// </summary>
        /// <returns>A list of shards.</returns>
        public async Task <List <Shard> > GetShardsAsync()
        {
            var json = await requester.CreateGetRequestAsync(StatusRootUrl, RootDomain, null, false);

            return(await Task.Factory.StartNew(() => JsonConvert.DeserializeObject <List <Shard> >(json)));
        }
예제 #2
0
        /// <summary>
        /// Get a list of all champions asynchronously.
        /// </summary>
        /// <param name="region">Region from which to retrieve the data.</param>
        /// <param name="championData">Data to retrieve.</param>
        /// <param name="language">Language of the data to be retrieved.</param>
        /// <returns>A ChampionListStatic object containing all champions.</returns>
        public async Task <ChampionListStatic> GetChampionsAsync(Region region,
                                                                 ChampionData championData = ChampionData.none, Language language = Language.en_US)
        {
            var wrapper = cache.Get <string, ChampionListStaticWrapper>(ChampionsCacheKey);

            if (wrapper != null && language == wrapper.Language && championData == wrapper.ChampionData)
            {
                return(wrapper.ChampionListStatic);
            }
            var json = await requester.CreateGetRequestAsync(
                string.Format(ChampionRootUrl, region.ToString()),
                RootDomain,
                new List <string>
            {
                string.Format("locale={0}", language.ToString()),
                championData == ChampionData.none ?
                string.Empty :
                string.Format("champData={0}", championData.ToString())
            });

            var champs = await Task.Factory.StartNew(() =>
                                                     JsonConvert.DeserializeObject <ChampionListStatic>(json));

            wrapper = new ChampionListStaticWrapper(champs, language, championData);
            cache.Add(ChampionsCacheKey, wrapper, DefaultSlidingExpiry);
            return(wrapper.ChampionListStatic);
        }