/// <summary> /// Get a list of all summoner spells asynchronously. /// </summary> /// <param name="region">Region from which to retrieve the data.</param> /// <param name="summonerSpellData">Data to retrieve.</param> /// <param name="language">Language of the data to be retrieved.</param> /// <returns>A SummonerSpellListStatic object containing all summoner spells.</returns> public async Task <SummonerSpellListStatic> GetSummonerSpellsAsync(Region region, SummonerSpellData summonerSpellData = SummonerSpellData.none, Language language = Language.en_US) { var wrapper = Cache.Get <SummonerSpellListStaticWrapper>(SummonerSpellsCacheKey); if (wrapper != null && wrapper.Language == language && wrapper.SummonerSpellData == summonerSpellData) { return(wrapper.SummonerSpellListStatic); } var json = await requester.CreateRequestAsync( string.Format(SummonerSpellRootUrl, region.ToString()), RootDomain, new List <string> { string.Format("locale={0}", language.ToString()), summonerSpellData == SummonerSpellData.none ? string.Empty : string.Format("spellData={0}", summonerSpellData.ToString()) }); var spells = await Task.Factory.StartNew(() => JsonConvert.DeserializeObject <SummonerSpellListStatic>(json)); wrapper = new SummonerSpellListStaticWrapper(spells, language, summonerSpellData); Cache.Add(SummonerSpellsCacheKey, wrapper); return(wrapper.SummonerSpellListStatic); }
/// <summary> /// Get a list of all summoner spells asynchronously. /// </summary> /// <param name="region">Region from which to retrieve the data.</param> /// <param name="summonerSpellData">Data to retrieve.</param> /// <param name="language">Language of the data to be retrieved.</param> /// <returns>A SummonerSpellListStatic object containing all summoner spells.</returns> public async Task <SummonerSpellListStatic> GetSummonerSpellsAsync(Region region , SummonerSpellData summonerSpellData = SummonerSpellData.none, Language language = Language.en_US) { var wrapper = Cache.Get <SummonerSpellListStaticWrapper>(SummonerSpellsCacheKey); if (wrapper == null || wrapper.Language != language || wrapper.SummonerSpellData != summonerSpellData) { var json = await requester.CreateRequestAsync(string.Format(SummonerSpellRootUrl, region.ToString()) , new List <string>() { string.Format("locale={0}", language.ToString()) , summonerSpellData == SummonerSpellData.none ? string.Empty : string.Format("spellData={0}", summonerSpellData.ToString()) }); var spells = await JsonConvert.DeserializeObjectAsync <SummonerSpellListStatic>(json); wrapper = new SummonerSpellListStaticWrapper(spells, language, summonerSpellData); Cache.Add <SummonerSpellListStaticWrapper>(SummonerSpellsCacheKey, wrapper); } return(wrapper.SummonerSpellListStatic); }
/// <summary> /// /// </summary> /// <param name="region"></param> /// <param name="summonerSpellData"></param> /// <param name="language"></param> /// <returns></returns> public SummonerSpellListDtoStatic GetStaticSummonerSpells(Region region, SummonerSpellData summonerSpellData = SummonerSpellData.basic, Language language = Language.en_US) { var wrapper = cache.Get <string, SummonerSpellListStaticWrapper>(SummonerSpellsCacheKey); if (wrapper == null || wrapper.Language != language || wrapper.SummonerSpellData != summonerSpellData) { var json = requester.CreateGetRequest(StaticDataRootUrl + SummonerSpellsUrl, region, new List <string> { string.Format("locale={0}", language.ToString()), summonerSpellData == SummonerSpellData.basic ? string.Empty : string.Format(StaticTagsFormat, summonerSpellData.ToString()) }); var spells = JsonConvert.DeserializeObject <SummonerSpellListDtoStatic>(json); wrapper = new SummonerSpellListStaticWrapper(spells, language, summonerSpellData); cache.Add(SummonerSpellsCacheKey, wrapper, DefaultSlidingExpiry); } return(wrapper.SummonerSpellListStatic); }
/// <summary> /// Get a list of all summoner spells asynchronously. /// </summary> /// <param name="region">Region from which to retrieve the data.</param> /// <param name="summonerSpellData">Data to retrieve.</param> /// <param name="language">Language of the data to be retrieved.</param> /// <returns>A SummonerSpellListStatic object containing all summoner spells.</returns> public async Task<SummonerSpellListStatic> GetSummonerSpellsAsync(Region region , SummonerSpellData summonerSpellData = SummonerSpellData.none, Language language = Language.en_US) { var wrapper = Cache.Get<SummonerSpellListStaticWrapper>(SummonerSpellsCacheKey); if (wrapper == null || wrapper.Language != language || wrapper.SummonerSpellData != summonerSpellData) { var json = await requester.CreateRequestAsync(string.Format(SummonerSpellRootUrl, region.ToString()) , new List<string>() { string.Format("locale={0}", language.ToString()) , summonerSpellData == SummonerSpellData.none ? string.Empty : string.Format("spellData={0}", summonerSpellData.ToString()) }); var spells = await JsonConvert.DeserializeObjectAsync<SummonerSpellListStatic>(json); wrapper = new SummonerSpellListStaticWrapper(spells, language, summonerSpellData); Cache.Add<SummonerSpellListStaticWrapper>(SummonerSpellsCacheKey, wrapper); } return wrapper.SummonerSpellListStatic; }