public TwitterDirectMessageExtended(TwitterDirectMessage twitterDirectMessage, TweetListType TweetType, Decimal TwitterAccountID, Decimal CurrentTweetID, bool Streamed = false) { this.TwitterAccountID = TwitterAccountID; this.DirectMessageEnabled = true; this.ReplyEnabled = false; this.RetweetEnabled = false; this.DeleteTweetEnabled = true; this.IsRetweet = false; this.YourRetweetVisibility = Visibility.Collapsed; if (twitterDirectMessage == null) return; this.UnRead = twitterDirectMessage.Id > CurrentTweetID && twitterDirectMessage.Sender.Id != TwitterAccountID; this.User = new MetroTwitUser((User) null); this.TweetType = TweetType; if (twitterDirectMessage.Text != null) this.RawText = twitterDirectMessage.Text; this.ID = twitterDirectMessage.Id; DateTime createdDate = twitterDirectMessage.CreatedDate; bool flag = 1 == 0; this.CreatedDate = twitterDirectMessage.CreatedDate; this.Source = twitterDirectMessage.Sender.ScreenName; if (twitterDirectMessage.Recipient.ScreenName == App.AppState.Accounts[this.TwitterAccountID].TwitterAccountName) { this.DMText = "From"; this.User.ScreenName = twitterDirectMessage.Sender.ScreenName; this.User.Name = twitterDirectMessage.Sender.Name; this.User.Id = twitterDirectMessage.Sender.Id; this.Source = twitterDirectMessage.Sender.ScreenName; } else { this.DMText = "To"; this.User.ScreenName = twitterDirectMessage.Recipient.ScreenName; this.User.Name = twitterDirectMessage.Recipient.Name; this.User.Id = twitterDirectMessage.Recipient.Id; this.Source = twitterDirectMessage.Sender.ScreenName; this.IsSelfTweet = true; this.CanUndoTweet = this.CreatedDate >= DateTime.Now.AddMinutes(-30.0); } this.BlockEnabled = this.User.ScreenName.ToLower() != App.AppState.Accounts[this.TwitterAccountID].TwitterAccountName.ToLower(); this.SpamEnabled = this.BlockEnabled; this.GeoVisibility = Visibility.Collapsed; this.ReplyToVisibility = Visibility.Collapsed; this.FavouriteVisible = Visibility.Collapsed; this.RetweetVisibility = Visibility.Collapsed; this.RetweetCountVisibility = Visibility.Collapsed; App.AppState.Accounts[this.TwitterAccountID].Cache.AddIntellisenseUser(twitterDirectMessage.Sender.ScreenName, twitterDirectMessage.Sender.ProfileImageSecureLocation); App.AppState.Accounts[this.TwitterAccountID].Cache.AddIntellisenseUser(twitterDirectMessage.Recipient.ScreenName, twitterDirectMessage.Recipient.ProfileImageSecureLocation); if (Streamed || twitterDirectMessage.Entities == null) this.Entities = RegularExpressions.ExtractEntities(this.RawText); else this.Entities = twitterDirectMessage.Entities; if (this.Entities != null) App.AppState.Accounts[this.TwitterAccountID].Cache.AddIntellisenseHashTags(Enumerable.Select<HashTagEntity, string>(Enumerable.OfType<HashTagEntity>((IEnumerable) this.Entities), (Func<HashTagEntity, string>) (hashTag => "#" + hashTag.Text))); }
public TweetListViewModel(Guid UniqueID, TweetListType tweetListType, Decimal TwitterAccountID, MetroTwitColumn Settings, string columntitle = null, string searchterm = null, string searchName = null, Decimal? existingSearchID = null, bool dontloadtweets = false, MetroTwitStatusBase originaltweet = null, Decimal InitialLastID = 0M) { TweetListViewModel tweetListViewModel = this; this.Settings = Settings; this.UniqueTweetListID = UniqueID != Guid.Empty ? UniqueID : Guid.NewGuid(); this.RefreshCommand = new RelayCommand(new Action(this.RefreshExecute)); this.FlushCommand = new RelayCommand<bool>(new Action<bool>(this.Flush)); this.RemoveColumnCommand = new RelayCommand(new Action(this.RemoveColumn)); this.ContentLinkCommand = new RelayCommand<string>(new Action<string>(this.ExecuteLink)); this.LinkCommand = new RelayCommand(new Action(this.OpenLink)); this.ProfileLinkCommand = new RelayCommand(new Action(this.ProfileLink)); this.MarkasReadCommand = new RelayCommand(new Action(this.MarkasRead)); this.FollowCommand = new RelayCommand(new Action(this.Follow)); this.BlockCommand = new RelayCommand(new Action(this.Block)); this.ReportSpamCommand = new RelayCommand(new Action(this.ReportSpam)); this.MentionCommand = new RelayCommand(new Action(this.Mention)); this.DirectMessageCommand = new RelayCommand(new Action(this.DirectMessage)); this.CloseAdCommand = new RelayCommand(new Action(this.CloseAd)); this.ColumnSettingsCommand = new RelayCommand(new Action(this.ColumnSettings)); this.UnpauseColumnCommand = new RelayCommand(new Action(this.UnpauseColumn)); this.SaveRemoveSearchCommand = new RelayCommand(new Action(this.SaveRemoveSearch)); this.NoRetweetsCommand = new RelayCommand(new Action(this.NoRetweets)); this.AddToListCommand = new RelayCommand(new Action(this.AddToList)); this.ResetColumnWidthCommand = new RelayCommand(new Action(this.ResetColumnWidth)); this.EnableNotifications = true; this.TweetType = tweetListType; this.TwitterAccountID = TwitterAccountID; this.IsPaused = false; this.ShowLoading = true; this.NameVisible = true; this.TweetPanelVisible = true; this.TitleBarVisible = true; this.FollowButtonIsEnabled = true; this.DisplayType = DisplayType.Tweets; this.ResetWidthVisibility = this.Settings.ColumnIsSetWidth; this.hideLoadLock = new object(); this.Tweets = new SortableObservableCollection<MetroTwitStatusBase>(new List<MetroTwitStatusBase>()); BindingOperations.EnableCollectionSynchronization((IEnumerable)this.Tweets, this._tweetsLock); switch (tweetListType) { case TweetListType.FriendsTimeline: this.TweetListName = "friends"; break; case TweetListType.DirectMessages: this.TweetListName = "direct messages"; break; case TweetListType.Search: this.SearchID = existingSearchID; if (searchterm == null) return; this.SearchName = searchName; this.TwitterTerm = searchterm.Trim().Replace("\n", ""); this.TweetListName = !string.IsNullOrEmpty(searchName) ? searchName : this.TwitterTerm; this.SearchDetailsVisible = true; this.SetSaveRemoveSearchButton(); break; case TweetListType.UserTimeline: if (searchterm == null) return; this.TwitterTerm = searchterm.Trim().Replace("\n", "").Replace("@", ""); this.TweetListName = "@" + this.TwitterTerm; if (!dontloadtweets) { this.ShowProfileLoading = true; this.ProfileDetailsVisible = true; if (App.AppState.Accounts[this.TwitterAccountID].IsSignedIn) Users.ShowAsync(App.AppState.Accounts[this.TwitterAccountID].Tokens, this.TwitterTerm, MetroTwitTwitterizer.Options).ContinueWith(new Action<Task<TwitterResponse<User>>>(this.UserDetails)); break; } else break; case TweetListType.List: if (searchterm == null) return; this.TwitterTerm = searchterm.Trim(); this.TweetListName = this.TwitterTerm; break; case TweetListType.MentionsMyTweetsRetweeted: SettingsData settingsData = SettingsData.Instance; this.TweetListName = "mentions"; settingsData = (SettingsData)null; break; case TweetListType.MyTweets: this.TweetListName = "my tweets"; break; case TweetListType.Favourites: this.TweetListName = "favourites"; break; case TweetListType.Conversation: this.TweetListName = "tweet conversation"; if (originaltweet != null) { this.TwitterTerm = originaltweet.InReplyToScreenName; originaltweet.TwitterAccountID = this.TwitterAccountID; originaltweet.TweetType = TweetListType.Conversation; originaltweet.ReplyToVisibility = Visibility.Collapsed; this.AddTweet(originaltweet); ++this.taskCount; this.ShowContentPanel(); break; } else break; case TweetListType.RetweetUsers: this.TweetListName = "retweeted by"; this.TwitterTerm = searchterm; break; } if (!string.IsNullOrEmpty(columntitle)) this.TweetListName = columntitle; if (!dontloadtweets) { Messenger.Default.Register<GenericMessage<object>>((object)this, (object)(((object)ViewModelMessages.RestUpdate).ToString() + this.UniqueTweetListID.ToString()), new Action<GenericMessage<object>>(this.RestUpdate)); ++this.taskCount; Task.Run((Action)(() => TwitterREST.TwitterRest(tweetListViewModel.UniqueTweetListID, tweetListType, tweetListViewModel.TwitterAccountID, tweetListViewModel.TweetType != TweetListType.Conversation ? RefreshTypes.Normal : RefreshTypes.ForeverScroll, new Action(tweetListViewModel.ShowContentPanel), tweetListViewModel.TwitterTerm, originaltweet != null ? originaltweet.InReplyTo : new Decimal(0), InitialLastID, new Decimal(0), tweetListViewModel.ListRetweets))); Messenger.Default.Register<GenericMessage<object>>((object)this, (object)this.MultiAccountifyToken((Enum)ViewModelMessages.DeleteTweet), new Action<GenericMessage<object>>(this.DeleteTweet)); Messenger.Default.Register<GenericMessage<object>>((object)this, (object)this.MultiAccountifyToken((Enum)ViewModelMessages.DeleteUserTweets), new Action<GenericMessage<object>>(this.DeleteUserTweets)); Messenger.Default.Register<GenericMessage<KeyValuePair<Decimal, bool>>>((object)this, (object)this.MultiAccountifyToken((Enum)ViewModelMessages.Blocked), new Action<GenericMessage<KeyValuePair<Decimal, bool>>>(this.Blocked)); Messenger.Default.Register<GenericMessage<object>>((object)this, (object)ViewModelMessages.EnableReplyOptions, new Action<GenericMessage<object>>(this.EnableReplyOptions)); if (tweetListType != TweetListType.DirectMessages) { if (tweetListType == TweetListType.FriendsTimeline || tweetListType == TweetListType.MyTweets || tweetListType == TweetListType.MentionsMyTweetsRetweeted || tweetListType == TweetListType.Conversation) { Messenger.Default.Register<GenericMessage<object>>((object)this, (object)this.MultiAccountifyToken((Enum)ViewModelMessages.StreamingStatusReceived), new Action<GenericMessage<object>>(this.StreamingUpdate)); Messenger.Default.Register<GenericMessage<object>>((object)this, (object)this.MultiAccountifyToken((Enum)ViewModelMessages.StreamingStatusDeleted), new Action<GenericMessage<object>>(this.StreamingDelete)); } Messenger.Default.Register<GenericMessage<object>>((object)this, (object)this.MultiAccountifyToken((Enum)ViewModelMessages.RemoveFavouriteTweet), new Action<GenericMessage<object>>(this.RemoveFavouriteTweet)); Messenger.Default.Register<GenericMessage<object>>((object)this, (object)this.MultiAccountifyToken((Enum)ViewModelMessages.FavouriteTweet), new Action<GenericMessage<object>>(this.FavouriteTweet)); } else { Messenger.Default.Register<GenericMessage<object>>((object)this, (object)this.MultiAccountifyToken((Enum)ViewModelMessages.StreamingDirectMessage), new Action<GenericMessage<object>>(this.StreamingDMUpdate)); Messenger.Default.Register<GenericMessage<object>>((object)this, (object)this.MultiAccountifyToken((Enum)ViewModelMessages.StreamingDirectMessageDeleted), new Action<GenericMessage<object>>(this.StreamingDMDelete)); } } if (this.DataContextInitialised != null) this.DataContextInitialised((object)this, EventArgs.Empty); }
public TwitterStatusExtended(Status twitterStatus, TweetListType TweetType, Decimal TwitterAccountID, Decimal CurrentTweetID) { this.TwitterAccountID = TwitterAccountID; this.DirectMessageEnabled = true; this.ReplyEnabled = true; this.RetweetEnabled = true; this.DeleteTweetEnabled = false; if (twitterStatus == null) return; this.UnRead = twitterStatus.Id > CurrentTweetID; this.TweetType = TweetType; App.AppState.Accounts[this.TwitterAccountID].Cache.AddIntellisenseUser(twitterStatus.User.ScreenName, twitterStatus.User.ProfileImageSecureLocation); DateTime createdDate = twitterStatus.CreatedDate; bool flag = 1 == 0; this.CreatedDate = twitterStatus.CreatedDate; this.IsFavourited = twitterStatus.IsFavorited; this.DeleteTweetEnabled = twitterStatus.User.ScreenName.ToLower() == App.AppState.Accounts[this.TwitterAccountID].TwitterAccountName.ToLower(); this.IsSelfTweet = this.DeleteTweetEnabled; this.CanUndoTweet = this.IsSelfTweet && this.CreatedDate >= DateTime.Now.AddMinutes(-30.0) && twitterStatus.RetweetedStatus == null; if (twitterStatus.RetweetedStatus == null) { this.IsRetweet = false; this.RetweetVisibility = Visibility.Collapsed; this.YourRetweetVisibility = Visibility.Collapsed; this.RetweetUser = (MetroTwitUser) null; this.RetweetPiP = false; this.ID = twitterStatus.Id; this.RetweetEnabled = !twitterStatus.User.IsProtected; } else { this.IsRetweet = true; this.RetweetVisibility = Visibility.Visible; this.RetweetUser = new MetroTwitUser(twitterStatus.User); this.YourRetweetVisibility = this.RetweetUser.ScreenName.ToLower() == App.AppState.Accounts[this.TwitterAccountID].TwitterAccountName.ToLower() ? Visibility.Visible : Visibility.Collapsed; this.RetweetPiP = true; this.RetweetEnabled = !twitterStatus.RetweetedStatus.User.IsProtected; this.ID = twitterStatus.Id; this.OriginalID = twitterStatus.RetweetedStatus.Id; twitterStatus = twitterStatus.RetweetedStatus; this.RetweetText = this.RetweetUser.Name; } if (twitterStatus.RetweetCount >= 1) { this.RetweetVisibility = Visibility.Collapsed; this.RetweetCountVisibility = Visibility.Visible; string str = twitterStatus.RetweetCount > 1 ? " people" : " person"; if (this.RetweetUser != null) { if (twitterStatus.RetweetCount > 1) this.RetweetText = string.Concat(new object[4] { (object) this.RetweetText, (object) " & ", (object) twitterStatus.RetweetCount, (object) str }); } else this.RetweetText = twitterStatus.RetweetCount + str; if (this.OriginalID == new Decimal(0)) this.OriginalID = this.ID; } else this.RetweetCountVisibility = Visibility.Collapsed; this.RawText = twitterStatus.Text; this.User = new MetroTwitUser(twitterStatus.User); this.BlockEnabled = this.User.ScreenName.ToLower() != App.AppState.Accounts[this.TwitterAccountID].TwitterAccountName.ToLower(); this.SpamEnabled = this.BlockEnabled; if (twitterStatus.Source != null) this.Source = WebUtility.HtmlDecode(twitterStatus.Source); this.InReplyToScreenName = twitterStatus.InReplyToScreenName; this.InReplyTo = twitterStatus.InReplyToStatusId; this.Geo = twitterStatus.Place; this.Coordinates = twitterStatus.Coordinates; this.GeoVisibility = this.Geo != null ? Visibility.Visible : Visibility.Collapsed; this.ReplyToVisibility = !(this.InReplyTo > new Decimal(0)) || TweetType == TweetListType.Conversation ? Visibility.Collapsed : Visibility.Visible; this.FavouriteVisible = Visibility.Visible; App.AppState.Accounts[this.TwitterAccountID].Cache.AddIntellisenseUser(twitterStatus.User.ScreenName, twitterStatus.User.ProfileImageSecureLocation); if (twitterStatus.Entities == null) { this.Entities = RegularExpressions.ExtractEntities(this.RawText); } else { App.AppState.Accounts[this.TwitterAccountID].Cache.AddIntellisenseHashTags(Enumerable.Select<HashTagEntity, string>(Enumerable.OfType<HashTagEntity>((IEnumerable) twitterStatus.Entities), (Func<HashTagEntity, string>) (hashTag => "#" + hashTag.Text))); this.Entities = twitterStatus.Entities; } switch (TweetType) { case TweetListType.MentionsMyTweetsRetweeted: this.DefaultGridVisible = Visibility.Collapsed; this.ReplyGridVisible = Visibility.Visible; break; case TweetListType.MyTweets: this.ReplyEnabled = false; this.RetweetEnabled = false; break; } foreach (UrlEntity u in Enumerable.ToArray<UrlEntity>(Enumerable.OfType<UrlEntity>((IEnumerable) this.Entities))) { MediaEntity media = MediaManager.CheckEntityandCreateMedia(u); if (media != null) { this.Entities.Remove((Entity) u); this.Entities.Add((Entity) media); } } this.Media = Enumerable.OfType<MediaEntity>((IEnumerable) this.Entities); this.ContainsMedia = Enumerable.Count<MediaEntity>(this.Media) > 0; if (this.ContainsMedia) this.MediaThumbnail = Enumerable.FirstOrDefault<MediaEntity>(this.Media); }
private void TryAddColumn(bool existing, TweetListViewModel existingColumnModel, TweetListType columnType, string searchTerm, string searchName, Decimal? existingSearchID) { bool flag = false; TweetListViewModel tweetListViewModel1 = existingColumnModel; foreach (TweetListViewModel tweetListViewModel2 in (Collection<TweetListViewModel>)this.ColumnsToShow) { if (!existing) tweetListViewModel1 = new TweetListViewModel(Guid.Empty, columnType, this.TwitterAccountID, new MetroTwitColumn(), string.Empty, searchTerm, searchName, existingSearchID, true, (MetroTwitStatusBase)null, new Decimal(0)); if (tweetListViewModel2.TweetListName == tweetListViewModel1.TweetListName && tweetListViewModel2.TweetType == tweetListViewModel1.TweetType) { flag = true; break; } } if (!flag) { TweetListViewModel tweetListViewModel2 = existingColumnModel; if (!existing) tweetListViewModel2 = columnType != TweetListType.DirectMessages ? (columnType != TweetListType.MentionsMyTweetsRetweeted ? (columnType != TweetListType.FriendsTimeline ? new TweetListViewModel(Guid.Empty, columnType, this.TwitterAccountID, new MetroTwitColumn(), string.Empty, searchTerm, searchName, existingSearchID, false, (MetroTwitStatusBase)null, new Decimal(0)) : App.AppState.Accounts[this.TwitterAccountID].TwitViewModel.FriendsVM) : App.AppState.Accounts[this.TwitterAccountID].TwitViewModel.MentionsVM) : App.AppState.Accounts[this.TwitterAccountID].TwitViewModel.DirectMessagesVM; if (tweetListViewModel2.TweetType != TweetListType.DirectMessages && tweetListViewModel2.TweetType != TweetListType.MentionsMyTweetsRetweeted) { tweetListViewModel2.ToastNotification = false; tweetListViewModel2.TaskbarNotification = false; tweetListViewModel2.SoundNotification = false; } this.ColumnsToShow.Add(tweetListViewModel2); tweetListViewModel2.ChangetoSavedColumn(); if (App.AppState.Accounts[this.TwitterAccountID].Settings.SyncColumns) NestService.ColumnsSync(new NestSync() { Add = { (object) new NestColumn() { Name = tweetListViewModel2.TweetListName, Type = (int) tweetListViewModel2.TweetType, Value = tweetListViewModel2.TwitterTerm, Date = DateTime.UtcNow.ToUniversalTime(), LastReadId = 0 } } }, (Action<NestSync>)(r => this.NestUpdate(r)), this.TwitterAccountID); this.SetAddButtonsEnabled(tweetListViewModel2.TweetType, false); Messenger.Default.Send<GenericMessage<object>>(new GenericMessage<object>((object)-1), (object)this.MultiAccountifyToken((System.Enum)ViewModelMessages.ColumnsToShow)); } else this.UnableToAddColumn(); }
private void TryAddView(ViewType viewType, ViewModelType viewModelType, TweetListType columnType, string searchTerm, string searchName, Decimal? existingSearchID = null, MetroTwitStatusBase Tweet = null, TwitterList ListItem = null) { if (viewType == ViewType.Column) { this.TryAddColumn(false, (TweetListViewModel)null, columnType, searchTerm, searchName, existingSearchID); } else { if (viewType != ViewType.Popup) return; if (InlinePopup.CurrentInline != null) InlinePopup.CurrentInline.Close(); Messenger.Default.Send<GenericMessage<object>>(new GenericMessage<object>((object)null), (object)this.MultiAccountifyToken((System.Enum)ViewModelMessages.SetNewTweetEntryOptionsContainer)); UserControl view = (UserControl)null; switch (viewModelType) { case ViewModelType.TweetList: if (columnType == TweetListType.Conversation) { string replyToScreenName = Tweet.InReplyToScreenName; TweetListViewModel tweetListViewModel = new TweetListViewModel(Guid.Empty, columnType, this.TwitterAccountID, new MetroTwitColumn(), string.Empty, replyToScreenName, string.Empty, new Decimal?(), false, Tweet, Tweet.ID) { EnableNotifications = false, TitleBarVisible = false, SettingsVisible = false }; TweetListView tweetListView = new TweetListView(); tweetListView.DataContext = (object)tweetListViewModel; view = (UserControl)tweetListView; break; } else { TweetListViewModel tweetListViewModel; if (Tweet != null && Tweet.AdUrls != null && !string.IsNullOrEmpty(Tweet.AdUrls.friendship_url)) tweetListViewModel = new TweetListViewModel(Guid.Empty, columnType, this.TwitterAccountID, new MetroTwitColumn(), string.Empty, searchTerm, searchName, new Decimal?(), false, (MetroTwitStatusBase)null, new Decimal(0)) { EnableNotifications = false, AdFollowUrl = Tweet.AdUrls.friendship_url, TitleBarVisible = false, SettingsVisible = false }; else tweetListViewModel = new TweetListViewModel(Guid.Empty, columnType, this.TwitterAccountID, new MetroTwitColumn(), string.Empty, searchTerm, searchName, new Decimal?(), false, (MetroTwitStatusBase)null, new Decimal(0)) { EnableNotifications = false, TitleBarVisible = false, SettingsVisible = false }; tweetListViewModel.AllowPin = columnType != TweetListType.RetweetUsers; ProfileView profileView = new ProfileView(); profileView.DataContext = (object)tweetListViewModel; view = (UserControl)profileView; break; } case ViewModelType.Lists: ListsView listsView = new ListsView(); listsView.DataContext = (object)new ListsViewModel(this.TwitterAccountID) { PopupTitle = "lists", AllowPin = false }; view = (UserControl)listsView; break; case ViewModelType.Trends: TrendsView trendsView1 = new TrendsView(); TrendsView trendsView2 = trendsView1; TrendsViewModel trendsViewModel1 = new TrendsViewModel(); trendsViewModel1.TwitterAccountID = this.TwitterAccountID; trendsViewModel1.AllowPin = false; trendsViewModel1.PopupTitle = "twitter trends"; TrendsViewModel trendsViewModel2 = trendsViewModel1; trendsView2.DataContext = (object)trendsViewModel2; view = (UserControl)trendsView1; break; case ViewModelType.ManageList: ManageTwitterListView manageTwitterListView = new ManageTwitterListView(); manageTwitterListView.DataContext = (object)new ManageTwitterListViewModel(ListItem != null ? ListItem : (TwitterList)null, this.TwitterAccountID) { AllowPin = false, PopupTitle = (ListItem != null ? string.Format("Edit {0}", (object)ListItem.Name) : "create new list") }; view = (UserControl)manageTwitterListView; break; } PopupService.ShowView(view); } }
private void SetAddButtonsEnabled(TweetListType columnType, bool Enable) { switch (columnType) { case TweetListType.FriendsTimeline: this.AddFriendsEnabled = Enable; break; case TweetListType.DirectMessages: this.AddDirectEnabled = Enable; break; case TweetListType.MentionsMyTweetsRetweeted: this.AddRepliesEnabled = Enable; break; case TweetListType.MyTweets: this.AddMyTweetsEnabled = Enable; break; case TweetListType.Favourites: this.AddFavouriteEnabled = Enable; break; } }
internal void UpdateRateLimits(TweetListType TweetType, RateLimitResource rateLimiting, string additionalInfo = "") { try { if (this.RateLimits == null) { this.RateLimits = new RateLimitStatus(); this.RateLimits.Resources = new Dictionary<string, Dictionary<string, RateLimitResource>>(); } switch (TweetType) { case TweetListType.FriendsTimeline: if (!this.RateLimits.Resources.ContainsKey("statuses")) this.RateLimits.Resources.Add("statuses", new Dictionary<string, RateLimitResource>()); if (this.RateLimits.Resources["statuses"] != null && !this.RateLimits.Resources["statuses"].ContainsKey("/statuses/home_timeline")) this.RateLimits.Resources["statuses"].Add("/statuses/home_timeline", new RateLimitResource()); if (this.RateLimits.Resources["statuses"]["/statuses/home_timeline"] == null || rateLimiting.Limit <= 0) break; this.RateLimits.Resources["statuses"]["/statuses/home_timeline"] = rateLimiting; break; case TweetListType.DirectMessages: if (!this.RateLimits.Resources.ContainsKey("direct_messages")) this.RateLimits.Resources.Add("direct_messages", new Dictionary<string, RateLimitResource>()); if (additionalInfo == "R") { if (this.RateLimits.Resources["direct_messages"] != null && !this.RateLimits.Resources["direct_messages"].ContainsKey("/direct_messages")) this.RateLimits.Resources["direct_messages"].Add("/direct_messages", new RateLimitResource()); if (this.RateLimits.Resources["direct_messages"]["/direct_messages"] != null && rateLimiting.Limit > 0) this.RateLimits.Resources["direct_messages"]["/direct_messages"] = rateLimiting; } if (!(additionalInfo == "S")) break; if (this.RateLimits.Resources["direct_messages"] != null && !this.RateLimits.Resources["direct_messages"].ContainsKey("/direct_messages/sent")) this.RateLimits.Resources["direct_messages"].Add("/direct_messages/sent", new RateLimitResource()); if (this.RateLimits.Resources["direct_messages"]["/direct_messages/sent"] != null && rateLimiting.Limit > 0) this.RateLimits.Resources["direct_messages"]["/direct_messages/sent"] = rateLimiting; break; case TweetListType.Search: if (!this.RateLimits.Resources.ContainsKey("search")) this.RateLimits.Resources.Add("search", new Dictionary<string, RateLimitResource>()); if (this.RateLimits.Resources["search"] != null && !this.RateLimits.Resources["search"].ContainsKey("/search/tweets")) this.RateLimits.Resources["search"].Add("/search/tweets", new RateLimitResource()); if (this.RateLimits.Resources["search"]["/search/tweets"] == null || rateLimiting.Limit <= 0) break; this.RateLimits.Resources["search"]["/search/tweets"] = rateLimiting; break; case TweetListType.UserTimeline: if (!this.RateLimits.Resources.ContainsKey("statuses")) this.RateLimits.Resources.Add("statuses", new Dictionary<string, RateLimitResource>()); if (this.RateLimits.Resources["statuses"] != null && !this.RateLimits.Resources["statuses"].ContainsKey("/statuses/user_timeline")) this.RateLimits.Resources["statuses"].Add("/statuses/user_timeline", new RateLimitResource()); if (this.RateLimits.Resources["statuses"]["/statuses/user_timeline"] == null || rateLimiting.Limit <= 0) break; this.RateLimits.Resources["statuses"]["/statuses/user_timeline"] = rateLimiting; break; case TweetListType.List: if (!this.RateLimits.Resources.ContainsKey("lists")) this.RateLimits.Resources.Add("lists", new Dictionary<string, RateLimitResource>()); if (this.RateLimits.Resources["lists"] != null && !this.RateLimits.Resources["lists"].ContainsKey("/lists/statuses")) this.RateLimits.Resources["lists"].Add("/lists/statuses", new RateLimitResource()); if (this.RateLimits.Resources["lists"]["/lists/statuses"] == null || rateLimiting.Limit <= 0) break; this.RateLimits.Resources["lists"]["/lists/statuses"] = rateLimiting; break; case TweetListType.MentionsMyTweetsRetweeted: if (!this.RateLimits.Resources.ContainsKey("statuses")) this.RateLimits.Resources.Add("statuses", new Dictionary<string, RateLimitResource>()); if (additionalInfo == "M") { if (this.RateLimits.Resources["statuses"] != null && !this.RateLimits.Resources["statuses"].ContainsKey("/statuses/mentions_timeline")) this.RateLimits.Resources["statuses"].Add("/statuses/mentions_timeline", new RateLimitResource()); if (this.RateLimits.Resources["statuses"]["/statuses/mentions_timeline"] != null && rateLimiting.Limit > 0) this.RateLimits.Resources["statuses"]["/statuses/mentions_timeline"] = rateLimiting; } if (!(additionalInfo == "R")) break; if (this.RateLimits.Resources["statuses"] != null && !this.RateLimits.Resources["statuses"].ContainsKey("/statuses/retweets_of_me")) this.RateLimits.Resources["statuses"].Add("/statuses/retweets_of_me", new RateLimitResource()); if (this.RateLimits.Resources["statuses"]["/statuses/retweets_of_me"] != null && rateLimiting.Limit > 0) this.RateLimits.Resources["statuses"]["/statuses/retweets_of_me"] = rateLimiting; break; case TweetListType.MyTweets: if (!this.RateLimits.Resources.ContainsKey("statuses")) this.RateLimits.Resources.Add("statuses", new Dictionary<string, RateLimitResource>()); if (this.RateLimits.Resources["statuses"] != null && !this.RateLimits.Resources["statuses"].ContainsKey("/statuses/user_timeline")) this.RateLimits.Resources["statuses"].Add("/statuses/user_timeline", new RateLimitResource()); if (this.RateLimits.Resources["statuses"]["/statuses/user_timeline"] == null || rateLimiting.Limit <= 0) break; this.RateLimits.Resources["statuses"]["/statuses/user_timeline"] = rateLimiting; break; case TweetListType.Favourites: if (!this.RateLimits.Resources.ContainsKey("statuses")) this.RateLimits.Resources.Add("statuses", new Dictionary<string, RateLimitResource>()); if (this.RateLimits.Resources["statuses"] != null && !this.RateLimits.Resources["statuses"].ContainsKey("/favorites/list")) this.RateLimits.Resources["statuses"].Add("/favorites/list", new RateLimitResource()); if (this.RateLimits.Resources["statuses"]["/favorites/list"] == null || rateLimiting.Limit <= 0) break; this.RateLimits.Resources["statuses"]["/favorites/list"] = rateLimiting; break; case TweetListType.Conversation: if (!this.RateLimits.Resources.ContainsKey("statuses")) this.RateLimits.Resources.Add("statuses", new Dictionary<string, RateLimitResource>()); if (this.RateLimits.Resources["statuses"] != null && !this.RateLimits.Resources["statuses"].ContainsKey("/statuses/show/:id")) this.RateLimits.Resources["statuses"].Add("/statuses/show/:id", new RateLimitResource()); if (this.RateLimits.Resources["statuses"]["/statuses/show/:id"] == null || rateLimiting.Limit <= 0) break; this.RateLimits.Resources["statuses"]["/statuses/show/:id"] = rateLimiting; break; case TweetListType.RetweetUsers: if (!this.RateLimits.Resources.ContainsKey("statuses")) this.RateLimits.Resources.Add("statuses", new Dictionary<string, RateLimitResource>()); if (this.RateLimits.Resources["statuses"] != null && !this.RateLimits.Resources["statuses"].ContainsKey("/statuses/retweets/:id")) this.RateLimits.Resources["statuses"].Add("/statuses/retweets/:id", new RateLimitResource()); if (this.RateLimits.Resources["statuses"]["/statuses/retweets/:id"] == null || rateLimiting.Limit <= 0) break; this.RateLimits.Resources["statuses"]["/statuses/retweets/:id"] = rateLimiting; break; } } catch { } }
internal int RateLimitsLeft(TweetListType TweetType) { switch (TweetType) { case TweetListType.FriendsTimeline: if (this.RateLimits.Resources.ContainsKey("statuses") && this.RateLimits.Resources["statuses"] != null && (this.RateLimits.Resources["statuses"].ContainsKey("/statuses/home_timeline") && this.RateLimits.Resources["statuses"]["/statuses/home_timeline"] != null) && this.RateLimits.Resources["statuses"]["/statuses/home_timeline"].Reset > DateTime.UtcNow) return this.RateLimits.Resources["statuses"]["/statuses/home_timeline"].Remaining; else break; case TweetListType.DirectMessages: if (this.RateLimits.Resources.ContainsKey("direct_messages") && this.RateLimits.Resources["direct_messages"] != null && (this.RateLimits.Resources["direct_messages"].ContainsKey("/direct_messages") && this.RateLimits.Resources["direct_messages"]["/direct_messages"] != null) && (this.RateLimits.Resources["direct_messages"]["/direct_messages"].Reset > DateTime.UtcNow && this.RateLimits.Resources["direct_messages"].ContainsKey("/direct_messages/sent") && this.RateLimits.Resources["direct_messages"]["/direct_messages/sent"] != null) && this.RateLimits.Resources["direct_messages"]["/direct_messages/sent"].Reset > DateTime.UtcNow) return Math.Min(this.RateLimits.Resources["direct_messages"]["/direct_messages"].Remaining, this.RateLimits.Resources["direct_messages"]["/direct_messages/sent"].Remaining); else break; case TweetListType.Search: if (this.RateLimits.Resources.ContainsKey("search") && this.RateLimits.Resources["search"] != null && (this.RateLimits.Resources["search"].ContainsKey("/search/tweets") && this.RateLimits.Resources["search"]["/search/tweets"] != null) && this.RateLimits.Resources["search"]["/search/tweets"].Reset > DateTime.UtcNow) return this.RateLimits.Resources["search"]["/search/tweets"].Remaining; else break; case TweetListType.UserTimeline: if (this.RateLimits.Resources.ContainsKey("statuses") && this.RateLimits.Resources["statuses"] != null && (this.RateLimits.Resources["statuses"].ContainsKey("/statuses/user_timeline") && this.RateLimits.Resources["statuses"]["/statuses/user_timeline"] != null) && this.RateLimits.Resources["statuses"]["/statuses/user_timeline"].Reset > DateTime.UtcNow) return this.RateLimits.Resources["statuses"]["/statuses/user_timeline"].Remaining; else break; case TweetListType.List: if (this.RateLimits.Resources.ContainsKey("lists") && this.RateLimits.Resources["lists"] != null && (this.RateLimits.Resources["lists"].ContainsKey("/lists/statuses") && this.RateLimits.Resources["lists"]["/lists/statuses"] != null) && this.RateLimits.Resources["lists"]["/lists/statuses"].Reset > DateTime.UtcNow) return this.RateLimits.Resources["lists"]["/lists/statuses"].Remaining; else break; case TweetListType.MentionsMyTweetsRetweeted: if (this.RateLimits.Resources.ContainsKey("statuses") && this.RateLimits.Resources["statuses"] != null && (this.RateLimits.Resources["statuses"].ContainsKey("/statuses/mentions_timeline") && this.RateLimits.Resources["statuses"]["/statuses/mentions_timeline"] != null) && (this.RateLimits.Resources["statuses"]["/statuses/mentions_timeline"].Reset > DateTime.UtcNow && this.RateLimits.Resources["statuses"].ContainsKey("/statuses/retweets_of_me") && this.RateLimits.Resources["statuses"]["/statuses/retweets_of_me"] != null) && this.RateLimits.Resources["statuses"]["/statuses/retweets_of_me"].Reset > DateTime.UtcNow) return Math.Min(this.RateLimits.Resources["statuses"]["/statuses/mentions_timeline"].Remaining, this.RateLimits.Resources["statuses"]["/statuses/retweets_of_me"].Remaining); else break; case TweetListType.MyTweets: if (this.RateLimits.Resources.ContainsKey("statuses") && this.RateLimits.Resources["statuses"] != null && (this.RateLimits.Resources["statuses"].ContainsKey("/statuses/user_timeline") && this.RateLimits.Resources["statuses"]["/statuses/user_timeline"] != null) && this.RateLimits.Resources["statuses"]["/statuses/user_timeline"].Reset > DateTime.UtcNow) return this.RateLimits.Resources["statuses"]["/statuses/user_timeline"].Remaining; else break; case TweetListType.Favourites: if (this.RateLimits.Resources.ContainsKey("statuses") && this.RateLimits.Resources["statuses"] != null && (this.RateLimits.Resources["statuses"].ContainsKey("/favorites/list") && this.RateLimits.Resources["statuses"]["/favorites/list"] != null) && this.RateLimits.Resources["statuses"]["/favorites/list"].Reset > DateTime.UtcNow) return this.RateLimits.Resources["statuses"]["/favorites/list"].Remaining; else break; case TweetListType.Conversation: if (this.RateLimits.Resources.ContainsKey("statuses") && this.RateLimits.Resources["statuses"] != null && (this.RateLimits.Resources["statuses"].ContainsKey("/statuses/show/:id") && this.RateLimits.Resources["statuses"]["/statuses/show/:id"] != null) && this.RateLimits.Resources["statuses"]["/statuses/show/:id"].Reset > DateTime.UtcNow) return this.RateLimits.Resources["statuses"]["/statuses/show/:id"].Remaining; else break; case TweetListType.RetweetUsers: if (this.RateLimits.Resources.ContainsKey("statuses") && this.RateLimits.Resources["statuses"] != null && (this.RateLimits.Resources["statuses"].ContainsKey("/statuses/retweets/:id") && this.RateLimits.Resources["statuses"]["/statuses/retweets/:id"] != null) && this.RateLimits.Resources["statuses"]["/statuses/retweets/:id"].Reset > DateTime.UtcNow) return this.RateLimits.Resources["statuses"]["/statuses/retweets/:id"].Remaining; else break; default: return 1; } return 1; }
private TweetListView GetSpecialTweetListView(TweetListViewModel viewModel, TweetListType tweetListType, string title) { if (!App.PermanentSpecialTweetListViews.ContainsKey(this.TwitterAccountID)) App.PermanentSpecialTweetListViews.Add(this.TwitterAccountID, new Dictionary<TweetListType, TweetListView>()); if (!App.PermanentSpecialTweetListViews[this.TwitterAccountID].ContainsKey(tweetListType)) { viewModel.AllowPin = false; viewModel.PopupTitle = title; Dictionary<TweetListType, TweetListView> dictionary = App.PermanentSpecialTweetListViews[this.TwitterAccountID]; int num = (int)tweetListType; TweetListView tweetListView1 = new TweetListView(); tweetListView1.DataContext = (object)viewModel; TweetListView tweetListView2 = tweetListView1; dictionary.Add((TweetListType)num, tweetListView2); } TweetListView tweetListView = App.PermanentSpecialTweetListViews[this.TwitterAccountID][tweetListType]; if (tweetListView.DataContext is IPopupViewModel) (tweetListView.DataContext as IPopupViewModel).AllowPin = false; return tweetListView; }
public static void TwitterRest(Guid unqiueID, TweetListType TweetType, Decimal TwitterAccountID, RefreshTypes RefreshType, Action initialCallback, string SearchTerm = null, Decimal InReplyToID = 0M, Decimal LastUpdateID = 0M, Decimal OldestTweetID = 0M, bool ListRetweets = true) { Func<string> MessengerToken = (Func<string>)(() => ((object)ViewModelMessages.RestUpdate).ToString() + unqiueID.ToString()); Action<Task<TwitterResponse<SearchResult>>> continuationAction1 = (Action<Task<TwitterResponse<SearchResult>>>)(searchResponse => { Action local_0 = initialCallback; try { TwitterStatusCollection local_1 = searchResponse.Result.ResponseObject.Statuses ?? new TwitterStatusCollection(); Messenger.Default.Send<GenericMessage<object>>(new GenericMessage<object>((object)new MetroRestResponse<TwitterStatusCollection>() { Tweets = local_1, RefreshType = RefreshType, RequestResult = searchResponse.Result.Result, Error = searchResponse.Result.Errors }), (object)MessengerToken()); Messenger.Default.Send<GenericMessage<int>>(new GenericMessage<int>(-1), (object)ViewModelMessages.ProgressVisible); App.AppState.Accounts[TwitterAccountID].UpdateRateLimits(TweetType, searchResponse.Result.RateLimiting, ""); } catch { } finally { if (local_0 != null) { local_0(); local_0 = null; } } }); Action<Task<TwitterResponse<TwitterStatusCollection>>> continuationAction2 = (Action<Task<TwitterResponse<TwitterStatusCollection>>>)(response => { Action local_0 = initialCallback; try { TwitterStatusCollection local_1 = response.Result.ResponseObject ?? new TwitterStatusCollection(); Messenger.Default.Send<GenericMessage<object>>(new GenericMessage<object>((object)new MetroRestResponse<TwitterStatusCollection>() { Tweets = local_1, RefreshType = RefreshType, RequestResult = response.Result.Result, Error = response.Result.Errors }), (object)MessengerToken()); Messenger.Default.Send<GenericMessage<int>>(new GenericMessage<int>(-1), (object)ViewModelMessages.ProgressVisible); App.AppState.Accounts[TwitterAccountID].UpdateRateLimits(TweetType, response.Result.RateLimiting, ""); } catch { } finally { if (local_0 != null) local_0(); } }); try { Messenger.Default.Send<GenericMessage<int>>(new GenericMessage<int>(1), (object)ViewModelMessages.ProgressVisible); TimelineOptions timelineOptions = MetroTwitTwitterizer.TimelineOptions; if (TweetType != TweetListType.Search && TweetType != TweetListType.DirectMessages && TweetType != TweetListType.Favourites && TweetType != TweetListType.Conversation) { if (RefreshType != RefreshTypes.ForeverScroll) timelineOptions.SinceStatusId = LastUpdateID; else timelineOptions.MaxStatusId = OldestTweetID; } Action action1; switch (TweetType) { case TweetListType.FriendsTimeline: Timelines.HomeTimelineAsync(App.AppState.Accounts[TwitterAccountID].Tokens, timelineOptions).ContinueWith(continuationAction2); break; case TweetListType.DirectMessages: DirectMessagesOptions directMessageOptions = MetroTwitTwitterizer.DirectMessageOptions; DirectMessagesSentOptions sentMessageOptions = MetroTwitTwitterizer.DirectSentMessageOptions; if (RefreshType != RefreshTypes.ForeverScroll) { directMessageOptions.SinceStatusId = LastUpdateID; sentMessageOptions.SinceStatusId = LastUpdateID; } else { directMessageOptions.MaxStatusId = OldestTweetID; sentMessageOptions.MaxStatusId = OldestTweetID; } try { DirectMessages.SentAsync(App.AppState.Accounts[TwitterAccountID].Tokens, sentMessageOptions).ContinueWith((Action<Task<TwitterResponse<TwitterDirectMessageCollection>>>)(directMessagesSentResponse => { if (directMessagesSentResponse.Result.Result == RequestResult.Success) { DirectMessages.ReceivedAsync(App.AppState.Accounts[TwitterAccountID].Tokens, directMessageOptions).ContinueWith((Action<Task<TwitterResponse<TwitterDirectMessageCollection>>>)(directMessagesReceived => { if (directMessagesReceived.Result.Result == RequestResult.Success && directMessagesReceived.Result.ResponseObject != null && directMessagesSentResponse.Result.ResponseObject != null) { IOrderedEnumerable<TwitterDirectMessage> local_0 = Enumerable.OrderByDescending<TwitterDirectMessage, DateTime>(Enumerable.Union<TwitterDirectMessage>((IEnumerable<TwitterDirectMessage>)directMessagesReceived.Result.ResponseObject, (IEnumerable<TwitterDirectMessage>)directMessagesSentResponse.Result.ResponseObject), (Func<TwitterDirectMessage, DateTime>)(s => s.CreatedDate)) ?? (IOrderedEnumerable<TwitterDirectMessage>)new TwitterDirectMessageCollection(); Messenger.Default.Send<GenericMessage<object>>(new GenericMessage<object>((object)new MetroRestResponse<IEnumerable<TwitterDirectMessage>>() { Tweets = (IEnumerable<TwitterDirectMessage>)local_0, RefreshType = RefreshType, RequestResult = directMessagesReceived.Result.Result }), (object)MessengerToken()); Messenger.Default.Send<GenericMessage<int>>(new GenericMessage<int>(-1), (object)ViewModelMessages.ProgressVisible); if (initialCallback != null) { initialCallback(); initialCallback = (Action)null; } App.AppState.Accounts[TwitterAccountID].UpdateRateLimits(TweetType, directMessagesSentResponse.Result.RateLimiting, "S"); App.AppState.Accounts[TwitterAccountID].UpdateRateLimits(TweetType, directMessagesReceived.Result.RateLimiting, "R"); } else { IEnumerable<TwitterError> local_3 = directMessagesReceived.Result.Errors; if (local_3 != null) { Messenger.Default.Send<GenericMessage<object>>(new GenericMessage<object>((object)new MetroRestResponse<IEnumerable<TwitterDirectMessage>>() { Tweets = (IEnumerable<TwitterDirectMessage>)new TwitterDirectMessageCollection(), RefreshType = RefreshType, Error = local_3, RequestResult = directMessagesReceived.Result.Result }), (object)MessengerToken()); Messenger.Default.Send<GenericMessage<int>>(new GenericMessage<int>(-1), (object)ViewModelMessages.ProgressVisible); } if (initialCallback != null) { Messenger.Default.Send<GenericMessage<object>>(new GenericMessage<object>((object)null), (object)MessengerToken()); initialCallback(); initialCallback = (Action)null; } App.AppState.Accounts[TwitterAccountID].UpdateRateLimits(TweetType, directMessagesReceived.Result.RateLimiting, "R"); } })); } else { IEnumerable<TwitterError> local_0 = directMessagesSentResponse.Result.Errors; if (local_0 != null) { Messenger.Default.Send<GenericMessage<object>>(new GenericMessage<object>((object)new MetroRestResponse<IEnumerable<TwitterDirectMessage>>() { Tweets = (IEnumerable<TwitterDirectMessage>)new TwitterDirectMessageCollection(), RefreshType = RefreshType, Error = local_0, RequestResult = directMessagesSentResponse.Result.Result }), (object)MessengerToken()); Messenger.Default.Send<GenericMessage<int>>(new GenericMessage<int>(-1), (object)ViewModelMessages.ProgressVisible); } if (initialCallback != null) { Messenger.Default.Send<GenericMessage<object>>(new GenericMessage<object>((object)null), (object)MessengerToken()); initialCallback(); initialCallback = (Action)null; } App.AppState.Accounts[TwitterAccountID].UpdateRateLimits(TweetType, directMessagesSentResponse.Result.RateLimiting, "S"); } })); break; } catch { break; } case TweetListType.Search: SearchOptions searchOptions = MetroTwitTwitterizer.SearchOptions; if (RefreshType != RefreshTypes.ForeverScroll) searchOptions.SinceId = (Decimal)(long)LastUpdateID; else searchOptions.MaxId = (Decimal)(long)OldestTweetID; Search.SearchAsync(App.AppState.Accounts[TwitterAccountID].Tokens, SearchTerm, searchOptions).ContinueWith(continuationAction1); break; case TweetListType.UserTimeline: UserTimelineOptions userTimelineOptions1 = MetroTwitTwitterizer.UserTimelineOptions; userTimelineOptions1.IncludeRetweets = true; if (RefreshType != RefreshTypes.ForeverScroll) userTimelineOptions1.SinceStatusId = LastUpdateID; else userTimelineOptions1.MaxStatusId = OldestTweetID; userTimelineOptions1.ScreenName = SearchTerm.Replace("@", "").Trim(); Timelines.UserTimelineAsync(App.AppState.Accounts[TwitterAccountID].Tokens, userTimelineOptions1).ContinueWith(continuationAction2); break; case TweetListType.List: ListStatusesOptions listStatusesOptions = MetroTwitTwitterizer.ListStatusesOptions; listStatusesOptions.IncludeRetweets = ListRetweets; if (RefreshType != RefreshTypes.ForeverScroll) listStatusesOptions.SinceId = (Decimal)(long)LastUpdateID; else listStatusesOptions.MaxId = (Decimal)(long)OldestTweetID; string[] strArray = SearchTerm.Split(new char[1] { '/' }); Lists.StatusesAsync(App.AppState.Accounts[TwitterAccountID].Tokens, strArray[1], strArray[0].Replace("@", ""), listStatusesOptions).ContinueWith(continuationAction2); break; case TweetListType.MentionsMyTweetsRetweeted: Task<TwitterResponse<TwitterStatusCollection>> mentionsresponse = Timelines.MentionsAsync(App.AppState.Accounts[TwitterAccountID].Tokens, timelineOptions); mentionsresponse.Wait(); Action action2 = initialCallback; if (mentionsresponse.Result.Result == RequestResult.Success) { RetweetsOfMeOptions retweetsOfMeOptions = MetroTwitTwitterizer.RetweetsOfMeOptions; if (RefreshType != RefreshTypes.ForeverScroll) retweetsOfMeOptions.SinceStatusId = (Decimal)(long)LastUpdateID; else retweetsOfMeOptions.MaxStatusId = (Decimal)(long)OldestTweetID; Task<TwitterResponse<TwitterStatusCollection>> task = Timelines.RetweetsOfMeAsync(App.AppState.Accounts[TwitterAccountID].Tokens, retweetsOfMeOptions); task.Wait(); if (task.Result.Result == RequestResult.Success && task.Result.ResponseObject != null && mentionsresponse.Result.ResponseObject != null) { if (mentionsresponse.Result.ResponseObject.Count > 0) { foreach (Status status in Enumerable.Where<Status>((IEnumerable<Status>)Enumerable.ToArray<Status>((IEnumerable<Status>)task.Result.ResponseObject), (Func<Status, int, bool>)((x, r) => x.Id < Enumerable.Last<Status>((IEnumerable<Status>)mentionsresponse.Result.ResponseObject).Id))) task.Result.ResponseObject.Remove(status); } IOrderedEnumerable<Status> orderedEnumerable = Enumerable.OrderByDescending<Status, DateTime>(Enumerable.Union<Status>((IEnumerable<Status>)mentionsresponse.Result.ResponseObject, (IEnumerable<Status>)task.Result.ResponseObject), (Func<Status, DateTime>)(s => s.CreatedDate)); if (Enumerable.Count<Status>((IEnumerable<Status>)orderedEnumerable) > 0) { TwitterStatusCollection statusCollection = new TwitterStatusCollection(); statusCollection.AddTwitterRange<Status>(orderedEnumerable.ToList<Status>()); // statusCollection, (IEnumerable<Status>) Enumerable.ToList<Status>((IEnumerable<Status>) orderedEnumerable)); Messenger.Default.Send<GenericMessage<object>>(new GenericMessage<object>((object)new MetroRestResponse<TwitterStatusCollection>() { Tweets = statusCollection, RefreshType = RefreshType, RequestResult = task.Result.Result }), (object)MessengerToken()); Messenger.Default.Send<GenericMessage<int>>(new GenericMessage<int>(-1), (object)ViewModelMessages.ProgressVisible); } else continuationAction2(mentionsresponse); App.AppState.Accounts[TwitterAccountID].UpdateRateLimits(TweetType, mentionsresponse.Result.RateLimiting, "M"); App.AppState.Accounts[TwitterAccountID].UpdateRateLimits(TweetType, task.Result.RateLimiting, "R"); } else { continuationAction2(mentionsresponse); IEnumerable<TwitterError> errors = task.Result.Errors; if (errors != null) { Messenger.Default.Send<GenericMessage<object>>(new GenericMessage<object>((object)new MetroRestResponse<TwitterStatusCollection>() { Tweets = new TwitterStatusCollection(), RefreshType = RefreshType, Error = errors, RequestResult = task.Result.Result }), (object)MessengerToken()); Messenger.Default.Send<GenericMessage<int>>(new GenericMessage<int>(-1), (object)ViewModelMessages.ProgressVisible); } App.AppState.Accounts[TwitterAccountID].UpdateRateLimits(TweetType, task.Result.RateLimiting, "R"); } } else { IEnumerable<TwitterError> errors = mentionsresponse.Result.Errors; if (errors != null) { Messenger.Default.Send<GenericMessage<object>>(new GenericMessage<object>((object)new MetroRestResponse<TwitterStatusCollection>() { Tweets = new TwitterStatusCollection(), RefreshType = RefreshType, Error = errors, RequestResult = mentionsresponse.Result.Result }), (object)MessengerToken()); Messenger.Default.Send<GenericMessage<int>>(new GenericMessage<int>(-1), (object)ViewModelMessages.ProgressVisible); } App.AppState.Accounts[TwitterAccountID].UpdateRateLimits(TweetType, mentionsresponse.Result.RateLimiting, "M"); } if (action2 == null) break; action2(); action1 = (Action)null; break; case TweetListType.MyTweets: UserTimelineOptions userTimelineOptions2 = MetroTwitTwitterizer.UserTimelineOptions; userTimelineOptions2.IncludeRetweets = true; if (RefreshType != RefreshTypes.ForeverScroll) userTimelineOptions2.SinceStatusId = LastUpdateID; else userTimelineOptions2.MaxStatusId = OldestTweetID; Timelines.UserTimelineAsync(App.AppState.Accounts[TwitterAccountID].Tokens, userTimelineOptions2).ContinueWith(continuationAction2); break; case TweetListType.Favourites: ListFavoritesOptions favoritesOptions = MetroTwitTwitterizer.ListFavoritesOptions; if (RefreshType != RefreshTypes.ForeverScroll) favoritesOptions.SinceStatusId = (Decimal)(long)LastUpdateID; else favoritesOptions.MaxStatusId = (Decimal)(long)OldestTweetID; Favorites.ListAsync(App.AppState.Accounts[TwitterAccountID].Tokens, favoritesOptions).ContinueWith(continuationAction2); break; case TweetListType.Conversation: Decimal statusId1 = TweetType != TweetListType.Conversation || !(InReplyToID == new Decimal(0)) ? InReplyToID : LastUpdateID; if (!(statusId1 > new Decimal(0))) break; Task<TwitterResponse<Status>> task1 = Tweets.ShowAsync(App.AppState.Accounts[TwitterAccountID].Tokens, statusId1, MetroTwitTwitterizer.Options); task1.Wait(); Action action3 = initialCallback; try { Status responseObject1 = task1.Result.ResponseObject; TwitterStatusCollection statusCollection1 = new TwitterStatusCollection(); if (responseObject1 != null) statusCollection1.Add(responseObject1); Messenger.Default.Send<GenericMessage<object>>(new GenericMessage<object>((object)new MetroRestResponse<TwitterStatusCollection>() { Tweets = statusCollection1, RefreshType = RefreshType, RequestResult = task1.Result.Result, Error = task1.Result.Errors }), (object)MessengerToken()); App.AppState.Accounts[TwitterAccountID].UpdateRateLimits(TweetType, task1.Result.RateLimiting, ""); if (responseObject1 != null) { Decimal statusId2 = responseObject1.InReplyToStatusId; while (statusId2 > new Decimal(0)) { if (statusId2 > new Decimal(0)) { Task<TwitterResponse<Status>> task2 = Tweets.ShowAsync(App.AppState.Accounts[TwitterAccountID].Tokens, statusId2, MetroTwitTwitterizer.Options); task2.Wait(); try { Status responseObject2 = task2.Result.ResponseObject; TwitterStatusCollection statusCollection2 = new TwitterStatusCollection(); if (responseObject2 != null) statusCollection2.Add(responseObject2); Messenger.Default.Send<GenericMessage<object>>(new GenericMessage<object>((object)new MetroRestResponse<TwitterStatusCollection>() { Tweets = statusCollection2, RefreshType = RefreshType, RequestResult = task2.Result.Result, Error = task2.Result.Errors }), (object)MessengerToken()); statusId2 = responseObject2 == null ? new Decimal(0) : responseObject2.InReplyToStatusId; App.AppState.Accounts[TwitterAccountID].UpdateRateLimits(TweetType, task2.Result.RateLimiting, ""); } catch { Messenger.Default.Send<GenericMessage<int>>(new GenericMessage<int>(-1), (object)ViewModelMessages.ProgressVisible); } } } } } catch { Messenger.Default.Send<GenericMessage<int>>(new GenericMessage<int>(-1), (object)ViewModelMessages.ProgressVisible); } finally { if (action3 != null) { action3(); action1 = (Action)null; } } break; case TweetListType.RetweetUsers: Tweets.RetweetsAsync(App.AppState.Accounts[TwitterAccountID].Tokens, Decimal.Parse(SearchTerm), MetroTwitTwitterizer.RetweetsOptions).ContinueWith(continuationAction2); break; case TweetListType.Followers: Friendship.FollowersIdsAsync(App.AppState.Accounts[TwitterAccountID].Tokens, new UsersIdsOptions() { ScreenName = SearchTerm }).ContinueWith((Action<Task<TwitterResponse<UserIdCollection>>>)(r => Users.LookupAsync(App.AppState.Accounts[TwitterAccountID].Tokens, new LookupUsersOptions() { UserIds = (TwitterIdCollection)r.Result.ResponseObject }).Wait())); break; } } catch { } }