/// <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, RLolApiName rla) { var rut = new RUrlType(); rut.Add(type, rla); Add(region, rut); }
/// <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)); }
/// <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); }
/// <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); }
public RLolApiName Find(LolUrlType type) { if (ContainsUrlTypes(type)) { return(UrlTypes[type]); } else { return(null); } }
/// <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; }
/// <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)); } }
/// <summary> /// </summary> /// <param name="type"> /// </param> /// <param name="names"> /// </param> /// <param name="limits"> /// </param> /// <param name="methods"> /// </param> /// <returns> /// </returns> public RateLimitBuilder AddRateLimitFor(LolUrlType type, List <LolApiName> names, List <ApiLimit> limits, params LolApiMethodName[] methods) { var rla = new RLolApiName(); var rlan = new RLolApiMethodName(); rlan.Add(names, methods.Distinct().ToArray()); rlan.AddLimit(limits.ToArray()); rla.Add(rlan); if (!Limits.ContainsKey(type)) { Limits.TryAdd(type, rla); } else { Limits[type].Add(rlan); } return(this); }
public void Add(LolUrlType val, RLolApiMethodName rlan) { UrlTypes.TryAdd(val, new RLolApiName(rlan)); }
/// <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); }
public void Add(LolUrlType val, RLolApiName rlan) { UrlTypes.TryAdd(val, rlan); }
public CustomCacheRule(LolUrlType urlType, LolApiName apiName, TimeSpan expiryTime) { this.UrlType = urlType; this.ApiName = apiName; this.ExpiryTime = expiryTime; }
public bool ContainsUrlTypes(LolUrlType name) { return(UrlTypes.ContainsKey(name)); }
public UrlTypeAttribute(LolUrlType _apitype) { this.ApiType = _apitype; }
public RLolApiMethodName FindRate(string platform, LolUrlType type, LolApiName apiName, LolApiMethodName method) { return(Rates.Find(platform, type, apiName, method)); }
/// <summary> /// specify new rate-limit for api /// </summary> /// <param name="region"> /// </param> /// <param name="type"> /// </param> /// <param name="rla"> /// pre-defined when web-server starts /// </param> public void Add(string region, LolUrlType type, RLolApiName rla) { Rates.Add(region, type, rla); }
/// <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); }