コード例 #1
0
        public bool ContainsApiName(LolApiName name, LolApiMethodName method)
        {
            bool q1 = ApiMethods.Contains(method);
            bool q2 = Names.Contains(name);

            return(q1 && q2);
        }
        public LolApiUrl AddApi(LolApiName suffix1, double version)
        {
            LolApiUrl sff1 = new LolApiUrl(suffix1, version);

            this.RiotGamesApiUrls.Add(sff1);
            return(sff1);
        }
コード例 #3
0
 /// <summary>
 /// </summary>
 /// <param name="type">
 /// </param>
 /// <param name="name">
 /// </param>
 /// <param name="limits">
 /// </param>
 /// <param name="methods">
 /// </param>
 /// <returns>
 /// </returns>
 public RateLimitBuilder AddRateLimitFor(LolUrlType type, LolApiName name, List <ApiLimit> limits, params LolApiMethodName[] methods)
 {
     return(AddRateLimitFor(type, new List <LolApiName>()
     {
         name
     }, limits, methods));
 }
コード例 #4
0
 public void Add(LolApiName name, params LolApiMethodName[] val)
 {
     Add(new List <LolApiName>()
     {
         name
     }, val);
 }
コード例 #5
0
        /// <exception cref="OverflowException">
        /// The dictionary already contains the maximum number of elements ( <see cref="F:System.Int32.MaxValue" />).
        /// </exception>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="key" /> is null.
        /// </exception>
        public void Add(string region, LolUrlType type, LolApiName name, List <LolApiMethodName> apiMethods, List <ApiLimit> limits)
        {
            var rut = new RUrlType();

            rut.Add(type, new RLolApiMethodName(name, apiMethods, limits.ToArray()));
            Add(region, rut);
        }
コード例 #6
0
        /// <exception cref="KeyNotFoundException">
        /// The property is retrieved and <paramref name="key" /> does not exist in the collection.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="key" /> is null.
        /// </exception>
        public RLolApiMethodName Find(string region, LolUrlType type, LolApiName name, LolApiMethodName method)
        {
            var rut  = Find(region);
            var rla  = rut?.Find(type);
            var rlan = rla?.Find(name, method);

            return(rlan);
        }
コード例 #7
0
        /// <summary>
        /// get data from Retry-After
        /// </summary>
        /// <param name="prop">
        /// </param>
        /// <param name="name">
        /// </param>
        /// <param name="limitType">
        /// </param>
        /// <param name="retryAfterSeconds">
        /// value of Retry-After
        /// </param>
        /// <param name="region">
        /// </param>
        /// <param name="type">
        /// </param>
        /// <exception cref="RiotGamesApiException">
        /// Condition.
        /// </exception>
        public void SetRetryTime(string region, LolUrlType type, LolApiName name, RateLimitType limitType, LolApiMethodName method, int retryAfterSeconds)
        {
            var regionLimit = Rates.Find(region, type, name, method);

            if (regionLimit == null)
            {
                throw new RiotGamesApiException($"Undefined {limitType} limit type for region:{region},type:{type},name:{name}");
            }
            regionLimit.RetryAfter        = DateTime.Now.AddSeconds(retryAfterSeconds);
            regionLimit.UsedRateLimitType = limitType;
        }
コード例 #8
0
ファイル: Extension3.cs プロジェクト: msx752/RiotGamesAPI
        /// <exception cref="RiotGamesApiException">
        /// UrlTypeAttribute not found
        /// </exception>
        /// <exception cref="AmbiguousMatchException">
        /// More than one of the requested attributes was found.
        /// </exception>
        /// <exception cref="TypeLoadException">
        /// A custom attribute type cannot be loaded.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="source" /> or <paramref name="predicate" /> is null.
        /// </exception>
        /// <exception cref="InvalidOperationException">
        /// No element satisfies the condition in <paramref name="predicate" />.-or-The source
        /// sequence is empty.
        /// </exception>
        /// <exception cref="NotSupportedException">
        /// <paramref name="element" /> is not a constructor, method, property, event, type, or field.
        /// </exception>
        public static LolUrlType GetUrlType(this LolApiName enumVal)
        {
            var typeInfo = enumVal.GetType().GetTypeInfo();
            var v        = typeInfo.DeclaredMembers.First(x => x.Name == enumVal.ToString());
            var attr     = v?.GetCustomAttribute <UrlTypeAttribute>();

            if (attr == null)
            {
                throw new RiotGamesApiException("UrlTypeAttribute not found");
            }
            return(attr.ApiType);
        }
コード例 #9
0
        /// <summary>
        /// easy api requester
        /// </summary>
        /// <typeparam name="T">
        /// returns Type of Value
        /// </typeparam>
        /// <param name="apiType">
        /// specify api type version
        /// </param>
        /// <param name="version">
        /// specify api version
        /// </param>
        /// <returns>
        /// </returns>
        /// <exception cref="RiotGamesApiException">
        /// Condition.
        /// </exception>
        public IFor <T> SelectApi <T>(LolApiName apiType, double version = 3.0) where T : new()
        {
            var rit = new LolApiRequest <T> {
                UrlType = apiType.GetUrlType()
            };

            rit.BaseUrl = ApiSettings.ApiOptions.RiotGamesApis[rit.UrlType].ApiUrl;
            rit.ApiList = ApiSettings.ApiOptions.RiotGamesApis[rit.UrlType].RiotGamesApiUrls
                          .FirstOrDefault(p => p.ApiName == apiType && p.CompareVersion(version));
            if (rit.ApiList == null)
            {
                throw new RiotGamesApiException($"{rit.UrlType} is not defined in RiotGamesApiBuilder or selected version:{version} is not defined");
            }

            return(rit);
        }
コード例 #10
0
ファイル: CacheOption.cs プロジェクト: msx752/RiotGamesAPI
        /// <summary>
        /// add cache rule for non-static api
        /// </summary>
        /// <param name="urlType">
        /// api url type
        /// </param>
        /// <param name="apiName">
        /// api method name
        /// </param>
        /// <param name="expiryTime">
        /// expiry time (max-limit: 1 hour)
        /// </param>
        public void AddCacheRule(LolUrlType urlType, LolApiName apiName, TimeSpan expiryTime)
        {
            if (urlType != LolUrlType.Static)
            {
                if (expiryTime.Hours >= 1)
                {
                    expiryTime = new TimeSpan(1, 0, 0);
                }

                var found = FindCacheRule(urlType, apiName);
                if (found != null)
                {
                    CustomCacheRules.Remove(found);
                }
                CustomCacheRules.Add(new CustomCacheRule(urlType, apiName, expiryTime));
            }
        }
コード例 #11
0
 public CustomCacheRule(LolUrlType urlType, LolApiName apiName, TimeSpan expiryTime)
 {
     this.UrlType    = urlType;
     this.ApiName    = apiName;
     this.ExpiryTime = expiryTime;
 }
コード例 #12
0
ファイル: LolApiRate.cs プロジェクト: msx752/RiotGamesAPI
        public LolApiRateUrl For(LolApiName api)
        {
            LolApiRateUrl url = new LolApiRateUrl();

            return(url);
        }
コード例 #13
0
 public RLolApiMethodName(LolApiName name, List <LolApiMethodName> methods, params ApiLimit[] limits)
     : this(new List <LolApiName>() { name }, methods, limits)
 {
 }
コード例 #14
0
ファイル: CacheOption.cs プロジェクト: msx752/RiotGamesAPI
        /// <summary>
        /// finds exists cache rules
        /// </summary>
        /// <param name="urlType">
        /// </param>
        /// <param name="apiName">
        /// </param>
        /// <returns>
        /// </returns>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="source" /> or <paramref name="predicate" /> is null.
        /// </exception>
        public CustomCacheRule FindCacheRule(LolUrlType urlType, LolApiName apiName)
        {
            var found = CustomCacheRules.FirstOrDefault(p => p.UrlType == urlType && p.ApiName == apiName);

            return(found);
        }
コード例 #15
0
ファイル: CacheOption.cs プロジェクト: msx752/RiotGamesAPI
 /// <summary>
 /// removs cache rule
 /// </summary>
 /// <param name="urlType">
 /// </param>
 /// <param name="apiName">
 /// </param>
 public void RemoveCacheRule(LolUrlType urlType, LolApiName apiName)
 {
     CustomCacheRules.RemoveAll(p => p.UrlType == urlType && p.ApiName == apiName);
 }
コード例 #16
0
ファイル: LolRateLimit.cs プロジェクト: msx752/RiotGamesAPI
 public LolRateLimit(LolApiName name)
 {
     ApiName    = name;
     ApiMethods = new List <LolApiMethodName>();
 }
コード例 #17
0
ファイル: RLolApi.cs プロジェクト: msx752/RiotGamesAPI
 public RLolApiMethodName Find(LolApiName name, LolApiMethodName method)
 {
     return(Names.FirstOrDefault <RLolApiMethodName>(p => p.ContainsApiName(name, method)));
 }
コード例 #18
0
ファイル: RLolApi.cs プロジェクト: msx752/RiotGamesAPI
 public void Add(LolApiName name, RLolApiMethodName val)
 {
     Names.Add(val);
 }
コード例 #19
0
 public RLolApiMethodName FindRate(string platform, LolUrlType type, LolApiName apiName, LolApiMethodName method)
 {
     return(Rates.Find(platform, type, apiName, method));
 }
コード例 #20
0
 /// <summary>
 /// lol apiurl creator
 /// </summary>
 /// <param name="_newApiUrl">
 /// name of apiMethod
 /// </param>
 /// <param name="_version">
 /// version of Method
 /// </param>
 public LolApiUrl(LolApiName _newApiUrl, double _version)
 {
     ApiMethods = new List <LolApiMethod>();
     SetVersion(_version);
     ApiName = _newApiUrl;
 }