コード例 #1
0
        public void Initialize()
        {
            HttpHeaders["X-RateLimit-Remaining"]      = "-1";
            HttpHeaders["X-RateLimit-Limit"]          = "-1";
            HttpHeaders["X-RateLimit-Reset"]          = "-1";
            HttpHeaders["X-Access-Level"]             = "read-write-directmessages";
            HttpHeaders["X-MediaRateLimit-Remaining"] = "-1";
            HttpHeaders["X-MediaRateLimit-Limit"]     = "-1";
            HttpHeaders["X-MediaRateLimit-Reset"]     = "-1";

            _MaxCount           = -1;
            _RemainCount        = -1;
            _ResetTime          = new DateTime();
            _ResetTimeInSeconds = -1;
            AccessLevel         = ApiAccessLevel.None;
            _MediaMaxCount      = -1;
            _MediaRemainCount   = -1;
            _MediaResetTime     = new DateTime();

            //_UsingCount = -1
            var arg     = new ApiInformationChangedEventArgs();
            var changed = Changed;

            if (changed != null)
            {
                changed(this, arg);
            }
        }
コード例 #2
0
 public void WriteBackEventArgs(ApiInformationChangedEventArgs arg)
 {
     _MaxCount           = arg.ApiInfo.MaxCount;
     _RemainCount        = arg.ApiInfo.RemainCount;
     _ResetTime          = arg.ApiInfo.ResetTime;
     _ResetTimeInSeconds = arg.ApiInfo.ResetTimeInSeconds;
     _UsingCount         = arg.ApiInfo.UsingCount;
     Raise_Changed();
 }
コード例 #3
0
        private void Raise_Changed()
        {
            var arg     = new ApiInformationChangedEventArgs();
            var changed = Changed;

            if (changed != null)
            {
                changed(this, arg);
            }
            _MaxCount           = arg.ApiInfo.MaxCount;
            _RemainCount        = arg.ApiInfo.RemainCount;
            _ResetTime          = arg.ApiInfo.ResetTime;
            _ResetTimeInSeconds = arg.ApiInfo.ResetTimeInSeconds;
            //_UsingCount = arg.ApiInfo.UsingCount
        }
コード例 #4
0
ファイル: Twitter.cs プロジェクト: noqisofon/OpenTween
 private void Twitter_ApiInformationChanged(object sender, ApiInformationChangedEventArgs e)
 {
 }
コード例 #5
0
ファイル: Twitter.cs プロジェクト: noqisofon/OpenTween
        public bool GetInfoApi(ApiInfo info)
        {
            if (Twitter.AccountState != MyCommon.ACCOUNT_STATE.Valid) return true;

            if (MyCommon._endingFlag) return true;

            HttpStatusCode res = HttpStatusCode.BadRequest;
            var content = string.Empty;
            try
            {
                res = twCon.RateLimitStatus(ref content);
            }
            catch(Exception)
            {
                MyCommon.TwitterApiInfo.Initialize();
                return false;
            }

            if (res != HttpStatusCode.OK) return false;

            try
            {
                var limit = MyCommon.CreateDataFromJson<TwitterDataModel.RateLimitStatus>(content);
                var arg = new ApiInformationChangedEventArgs();
                arg.ApiInfo.MaxCount = limit.HourlyLimit;
                arg.ApiInfo.RemainCount = limit.RemainingHits;
                arg.ApiInfo.ResetTime = MyCommon.DateTimeParse(limit.RestTime);
                arg.ApiInfo.ResetTimeInSeconds = limit.RestTimeInSeconds;
                if (info != null)
                {
                    arg.ApiInfo.UsingCount = info.UsingCount;

                    info.MaxCount = arg.ApiInfo.MaxCount;
                    info.RemainCount = arg.ApiInfo.RemainCount;
                    info.ResetTime = arg.ApiInfo.ResetTime;
                    info.ResetTimeInSeconds = arg.ApiInfo.ResetTimeInSeconds;
                }

                if (ApiInformationChanged != null)
                {
                    ApiInformationChanged(this, arg);
                }
                MyCommon.TwitterApiInfo.WriteBackEventArgs(arg);
                return true;
            }
            catch(Exception ex)
            {
                MyCommon.TraceOut(ex, MethodBase.GetCurrentMethod().Name + " " + content);
                MyCommon.TwitterApiInfo.Initialize();
                return false;
            }
        }
コード例 #6
0
ファイル: Tween.cs プロジェクト: lupeeloveee/OpenTween
 private void SetStatusLabelApiHandler(object sender, ApiInformationChangedEventArgs e)
 {
     try
     {
         if (InvokeRequired && !IsDisposed)
         {
             Invoke(new SetStatusLabelApiDelegate(SetStatusLabelApi));
         }
         else
         {
             SetStatusLabelApi();
         }
     }
     catch (ObjectDisposedException)
     {
         return;
     }
     catch (InvalidOperationException)
     {
         return;
     }
 }
コード例 #7
0
 private void Raise_Changed()
 {
     var arg = new ApiInformationChangedEventArgs();
     var changed = Changed;
     if (changed != null)
     {
         changed(this, arg);
     }
     _MaxCount = arg.ApiInfo.MaxCount;
     _RemainCount = arg.ApiInfo.RemainCount;
     _ResetTime = arg.ApiInfo.ResetTime;
     _ResetTimeInSeconds = arg.ApiInfo.ResetTimeInSeconds;
     //_UsingCount = arg.ApiInfo.UsingCount
 }
コード例 #8
0
 public void WriteBackEventArgs(ApiInformationChangedEventArgs arg)
 {
     _MaxCount = arg.ApiInfo.MaxCount;
     _RemainCount = arg.ApiInfo.RemainCount;
     _ResetTime = arg.ApiInfo.ResetTime;
     _ResetTimeInSeconds = arg.ApiInfo.ResetTimeInSeconds;
     _UsingCount = arg.ApiInfo.UsingCount;
     Raise_Changed();
 }
コード例 #9
0
        public void Initialize()
        {
            if (HttpHeaders.ContainsKey("X-RateLimit-Remaining"))
            {
                HttpHeaders["X-RateLimit-Remaining"] = "-1";
            }
            else
            {
                HttpHeaders.Add("X-RateLimit-Remaining", "-1");
            }

            if (HttpHeaders.ContainsKey("X-RateLimit-Limit"))
            {
                HttpHeaders["X-RateLimit-Limit"] = "-1";
            }
            else
            {
                HttpHeaders.Add("X-RateLimit-Limit", "-1");
            }

            if (HttpHeaders.ContainsKey("X-RateLimit-Reset"))
            {
                HttpHeaders["X-RateLimit-Reset"] = "-1";
            }
            else
            {
                HttpHeaders.Add("X-RateLimit-Reset", "-1");
            }

            if (HttpHeaders.ContainsKey("X-Access-Level"))
            {
                HttpHeaders["X-Access-Level"] = "read-write-directmessages";
            }
            else
            {
                HttpHeaders.Add("X-Access-Level", "read-write-directmessages");
            }

            if (HttpHeaders.ContainsKey("X-MediaRateLimit-Remaining"))
            {
                HttpHeaders["X-MediaRateLimit-Remaining"] = "-1";
            }
            else
            {
                HttpHeaders.Add("X-MediaRateLimit-Remaining", "-1");
            }

            if (HttpHeaders.ContainsKey("X-MediaRateLimit-Limit"))
            {
                HttpHeaders["X-MediaRateLimit-Limit"] = "-1";
            }
            else
            {
                HttpHeaders.Add("X-MediaRateLimit-Limit", "-1");
            }

            if (HttpHeaders.ContainsKey("X-MediaRateLimit-Reset"))
            {
                HttpHeaders["X-MediaRateLimit-Reset"] = "-1";
            }
            else
            {
                HttpHeaders.Add("X-MediaRateLimit-Reset", "-1");
            }

            _MaxCount = -1;
            _RemainCount = -1;
            _ResetTime = new DateTime();
            _ResetTimeInSeconds = -1;
            AccessLevel = ApiAccessLevel.None;
            _MediaMaxCount = -1;
            _MediaRemainCount = -1;
            _MediaResetTime = new DateTime();

            //_UsingCount = -1
            var arg = new ApiInformationChangedEventArgs();
            var changed = Changed;
            if (changed != null)
            {
                changed(this, arg);
            }
        }