Ejemplo n.º 1
0
        /// <summary>
        /// Get a list of all masteries asynchronously.
        /// </summary>
        /// <param name="region">Region from which to retrieve the data.</param>
        /// <param name="masteryData">Data to retrieve.</param>
        /// <param name="language">Language of the data to be retrieved.</param>
        /// <returns>An MasteryListStatic object containing all masteries.</returns>
        public async Task <MasteryListStatic> GetMasteriesAsync(Region region,
                                                                MasteryData masteryData = MasteryData.none, Language language = Language.en_US)
        {
            var wrapper = Cache.Get <MasteryListStaticWrapper>(MasteriesCacheKey);

            if (wrapper != null && language == wrapper.Language && masteryData == wrapper.MasteryData)
            {
                return(wrapper.MasteryListStatic);
            }
            var json = await requester.CreateRequestAsync(
                string.Format(MasteryRootUrl, region.ToString()),
                RootDomain,
                new List <string>
            {
                string.Format("locale={0}", language.ToString()),
                masteryData == MasteryData.none ?
                string.Empty :
                string.Format("masteryListData={0}", masteryData.ToString())
            });

            var masteries = await Task.Factory.StartNew(() =>
                                                        JsonConvert.DeserializeObject <MasteryListStatic>(json));

            wrapper = new MasteryListStaticWrapper(masteries, language, masteryData);
            Cache.Add(MasteriesCacheKey, wrapper);
            return(wrapper.MasteryListStatic);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Get a list of all masteries asynchronously.
        /// </summary>
        /// <param name="region">Region from which to retrieve the data.</param>
        /// <param name="masteryData">Data to retrieve.</param>
        /// <param name="language">Language of the data to be retrieved.</param>
        /// <returns>An MasteryListStatic object containing all masteries.</returns>
        public async Task <MasteryListStatic> GetMasteriesAsync(Region region,
                                                                MasteryData masteryData = MasteryData.basic, Language language = Language.en_US)
        {
            var wrapper = cache.Get <string, MasteryListStaticWrapper>(MasteriesCacheKey);

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

            var sr = new StreamReader(resp.Payload);

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

            wrapper = new MasteryListStaticWrapper(masteries, language, masteryData);
            cache.Add(MasteriesCacheKey, wrapper, DefaultSlidingExpiry);
            return(wrapper.MasteryListStatic);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Get a list of all masteries asynchronously.
        /// </summary>
        /// <param name="region">Region from which to retrieve the data.</param>
        /// <param name="masteryData">Data to retrieve.</param>
        /// <param name="language">Language of the data to be retrieved.</param>
        /// <returns>An MasteryListStatic object containing all masteries.</returns>
        public async Task <MasteryListStatic> GetMasteriesAsync(Region region
                                                                , MasteryData masteryData = MasteryData.none, Language language = Language.en_US)
        {
            var wrapper = Cache.Get <MasteryListStaticWrapper>(MasteriesCacheKey);

            if (wrapper == null || language != wrapper.Language || masteryData != wrapper.MasteryData)
            {
                var json = await requester.CreateRequestAsync(string.Format(MasteryRootUrl, region.ToString())
                                                              , new List <string>() { string.Format("locale={0}", language.ToString())
                                                                                      , masteryData == MasteryData.none ? string.Empty
                            : string.Format("masteryListData={0}", masteryData.ToString()) });

                var masteries = await JsonConvert.DeserializeObjectAsync <MasteryListStatic>(json);

                wrapper = new MasteryListStaticWrapper(masteries, language, masteryData);
                Cache.Add <MasteryListStaticWrapper>(MasteriesCacheKey, wrapper);
            }
            return(wrapper.MasteryListStatic);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Get a list of all masteries synchronously.
        /// </summary>
        /// <param name="region">Region from which to retrieve the data.</param>
        /// <param name="masteryData">Data to retrieve.</param>
        /// <param name="language">Language of the data to be retrieved.</param>
        /// <returns>An MasteryListStatic object containing all masteries.</returns>
        public MasteryListStatic GetMasteries(Region region, MasteryData masteryData = MasteryData.none,
                                              Language language = Language.en_US)
        {
            var wrapper = cache.Get <string, MasteryListStaticWrapper>(MasteriesCacheKey);

            if (wrapper == null || language != wrapper.Language || masteryData != wrapper.MasteryData)
            {
                var json = requester.CreateGetRequest(
                    string.Format(MasteryRootUrl, region.ToString()),
                    RootDomain,
                    new List <string>
                {
                    string.Format("locale={0}", language.ToString()),
                    masteryData == MasteryData.none ?
                    string.Empty :
                    string.Format("masteryListData={0}", masteryData.ToString())
                });
                var masteries = JsonConvert.DeserializeObject <MasteryListStatic>(json);
                wrapper = new MasteryListStaticWrapper(masteries, language, masteryData);
                cache.Add(MasteriesCacheKey, wrapper, DefaultSlidingExpiry);
            }
            return(wrapper.MasteryListStatic);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Get a list of all masteries asynchronously.
 /// </summary>
 /// <param name="region">Region from which to retrieve the data.</param>
 /// <param name="masteryData">Data to retrieve.</param>
 /// <param name="language">Language of the data to be retrieved.</param>
 /// <returns>An MasteryListStatic object containing all masteries.</returns>
 public async Task<MasteryListStatic> GetMasteriesAsync(Region region
     , MasteryData masteryData = MasteryData.none, Language language = Language.en_US)
 {
     var wrapper = Cache.Get<MasteryListStaticWrapper>(MasteriesCacheKey);
     if (wrapper == null || language != wrapper.Language || masteryData != wrapper.MasteryData)
     {
         var json = await requester.CreateRequestAsync(string.Format(MasteryRootUrl, region.ToString())
             , new List<string>() { string.Format("locale={0}", language.ToString())
                 , masteryData == MasteryData.none ? string.Empty
                     : string.Format("masteryListData={0}", masteryData.ToString()) });
         var masteries = await JsonConvert.DeserializeObjectAsync<MasteryListStatic>(json);
         wrapper = new MasteryListStaticWrapper(masteries, language, masteryData);
         Cache.Add<MasteryListStaticWrapper>(MasteriesCacheKey, wrapper);
     }
     return wrapper.MasteryListStatic;
 }