コード例 #1
0
ファイル: StaticRiotApi.cs プロジェクト: echo000/TestProject2
        /// <summary>
        /// Get a list of all runes asynchronously.
        /// </summary>
        /// <param name="region">Region from which to retrieve the data.</param>
        /// <param name="runeData">Data to retrieve.</param>
        /// <param name="language">Language of the data to be retrieved.</param>
        /// <returns>A RuneListStatic object containing all runes.</returns>
        public async Task <RuneListStatic> GetRunesAsync(Region region, RuneData runeData = RuneData.basic,
                                                         Language language = Language.en_US)
        {
            var wrapper = cache.Get <string, RuneListStaticWrapper>(RunesCacheKey);

            if (wrapper != null && !(language != wrapper.Language | runeData != wrapper.RuneData))
            {
                return(wrapper.RuneListStatic);
            }
            var args = "{\"data\" : \"" + runeData.ToString() + "\", \"region\" : \"" + region.ToString() + "\"}";
            var ir   = new Amazon.Lambda.Model.InvokeRequest
            {
                FunctionName  = "arn:aws:lambda:us-east-1:907841483528:function:staticGetRune",
                PayloadStream = AWSSDKUtils.GenerateMemoryStreamFromString(args)
            };
            var json = "";
            var resp = await App.lambdaClient.InvokeAsync(ir);

            var sr = new StreamReader(resp.Payload);

            json = sr.ReadToEnd();
            var runes = await Task.Factory.StartNew(() =>
                                                    JsonConvert.DeserializeObject <RuneListStatic>(json));

            wrapper = new RuneListStaticWrapper(runes, language, runeData);
            cache.Add(RunesCacheKey, wrapper, DefaultSlidingExpiry);
            return(wrapper.RuneListStatic);
        }
コード例 #2
0
        /// <summary>
        /// Get a list of all runes asynchronously.
        /// </summary>
        /// <param name="region">Region from which to retrieve the data.</param>
        /// <param name="runeData">Data to retrieve.</param>
        /// <param name="language">Language of the data to be retrieved.</param>
        /// <returns>A RuneListStatic object containing all runes.</returns>
        public async Task <RuneListStatic> GetRunesAsync(Region region, RuneData runeData = RuneData.none,
                                                         Language language = Language.en_US)
        {
            var wrapper = Cache.Get <RuneListStaticWrapper>(RunesCacheKey);

            if (wrapper != null && !(language != wrapper.Language | runeData != wrapper.RuneData))
            {
                return(wrapper.RuneListStatic);
            }
            var json = await requester.CreateRequestAsync(
                string.Format(RuneRootUrl, region.ToString()),
                RootDomain,
                new List <string>
            {
                string.Format("locale={0}", language.ToString()),
                runeData == RuneData.none ?
                string.Empty :
                string.Format("runeListData={0}", runeData.ToString())
            });

            var runes = await Task.Factory.StartNew(() =>
                                                    JsonConvert.DeserializeObject <RuneListStatic>(json));

            wrapper = new RuneListStaticWrapper(runes, language, runeData);
            Cache.Add(RunesCacheKey, wrapper);
            return(wrapper.RuneListStatic);
        }
コード例 #3
0
ファイル: StaticRiotApi.cs プロジェクト: Karunp/RiotSharp
        /// <summary>
        /// Get a list of all runes synchronously.
        /// </summary>
        /// <param name="region">Region from which to retrieve the data.</param>
        /// <param name="runeData">Data to retrieve.</param>
        /// <param name="language">Language of the data to be retrieved.</param>
        /// <returns>A RuneListStatic object containing all runes.</returns>
        public RuneListStatic GetRunes(Region region, RuneData runeData = RuneData.none
                                       , Language language = Language.en_US)
        {
            var wrapper = Cache.Get <RuneListStaticWrapper>(RunesCacheKey);

            if (wrapper == null || language != wrapper.Language || runeData != wrapper.RuneData)
            {
                var json = requester.CreateRequest(string.Format(RuneRootUrl, region.ToString())
                                                   , new List <string>()
                {
                    string.Format("locale={0}", language.ToString())
                    , runeData == RuneData.none ? string.Empty
                            : string.Format("runeListData={0}", runeData.ToString())
                });
                var runes = JsonConvert.DeserializeObject <RuneListStatic>(json);
                wrapper = new RuneListStaticWrapper(runes, language, runeData);
                Cache.Add <RuneListStaticWrapper>(RunesCacheKey, wrapper);
            }
            return(wrapper.RuneListStatic);
        }
コード例 #4
0
ファイル: StaticRiotApi.cs プロジェクト: Karunp/RiotSharp
 /// <summary>
 /// Get a list of all runes asynchronously.
 /// </summary>
 /// <param name="region">Region from which to retrieve the data.</param>
 /// <param name="runeData">Data to retrieve.</param>
 /// <param name="language">Language of the data to be retrieved.</param>
 /// <returns>A RuneListStatic object containing all runes.</returns>
 public async Task<RuneListStatic> GetRunesAsync(Region region, RuneData runeData = RuneData.none
     , Language language = Language.en_US)
 {
     var wrapper = Cache.Get<RuneListStaticWrapper>(RunesCacheKey);
     if (wrapper == null || language != wrapper.Language | runeData != wrapper.RuneData)
     {
         var json = await requester.CreateRequestAsync(string.Format(RuneRootUrl, region.ToString())
             , new List<string>() { string.Format("locale={0}", language.ToString())
                 , runeData == RuneData.none ? string.Empty
                     : string.Format("runeListData={0}", runeData.ToString()) });
         var runes = await JsonConvert.DeserializeObjectAsync<RuneListStatic>(json);
         wrapper = new RuneListStaticWrapper(runes, language, runeData);
         Cache.Add<RuneListStaticWrapper>(RunesCacheKey, wrapper);
     }
     return wrapper.RuneListStatic;
 }