コード例 #1
0
        public Dictionary <string, string> GetRateLimitHeaders()
        {
            ThrottleInfo throttleInfo = getThrottleInfoFromCache();

            int requestsRemaining = Math.Max(RequestLimit - throttleInfo.RequestCount, 0);

            var headers = new Dictionary <string, string>();

            headers.Add("X-RateLimit-Limit", RequestLimit.ToString());
            headers.Add("X-RateLimit-Remaining", RequestsRemaining.ToString());
            headers.Add("X-RateLimit-Reset", toUnixTime(throttleInfo.ExpiresAt).ToString());
            return(headers);
        }
コード例 #2
0
        public Dictionary <string, string> GetRateLimitHeaders()
        {
            ThrottleInfo throttleInfo = GetThrottleInfoFromCache();

            int requestsRemaining = Math.Max(RequestLimit - throttleInfo.RequestCount, 0);

            var headers = new Dictionary <string, string>
            {
                { "X-RateLimit-Limit", RequestLimit.ToString() },
                { "X-RateLimit-Remaining", RequestsRemaining.ToString() },
                { "X-RateLimit-Reset", throttleInfo.ExpiresAt.ToString(CultureInfo.InvariantCulture) }
            };

            return(headers);
        }
コード例 #3
0
 protected virtual void OnRequestsRemaining(int Value)
 {
     RequestsRemaining?.Invoke(this, new CountEventArgs {
         Count = Value
     });
 }