public void Execute(object parameter) { TwitterStatus tweet = parameter as TwitterStatus; _pendingCalls = 0; var credentials = Config.ReadLaterCredentials; if (tweet == null) { return; } if (credentials.Pocket != null) { var service = new PocketService(); service.UserName = credentials.Pocket.User; service.Password = credentials.Pocket.Password; TwitterUrl link = tweet.Entities.FirstOrDefault(item => item != null && item.EntityType == TwitterEntityType.Url) as TwitterUrl; Dependency.Resolve <IMessageService>().SetLoadingBar(true, Resources.SavingForLater); _pendingCalls++; if (link != null) { service.AddUrl(link.ExpandedValue, tweet.Id, Callback); } else { string url = "http://twitter.com/" + tweet.Author.ScreenName + "/statuses/" + tweet.Id.ToString(); service.AddUrl(url, Callback); } } if (credentials.Instapaper != null) { var service = new InstapaperService(); service.UserName = credentials.Instapaper.User; service.Password = credentials.Instapaper.Password; TwitterUrl link = tweet.Entities.FirstOrDefault(item => item != null && item.EntityType == TwitterEntityType.Url) as TwitterUrl; Dependency.Resolve <IMessageService>().SetLoadingBar(true, Resources.SavingForLater); _pendingCalls++; if (link != null) { service.AddUrl(link.ExpandedValue, tweet.Text, Callback); } else { string url = "http://twitter.com/" + tweet.Author.ScreenName + "/statuses/" + tweet.Id.ToString(); service.AddUrl(url, Callback); } } }
void SetCommands() { setCustomBackground = new DelegateCommand((obj) => { Navigate("/Pages/Settings/Backgrounds.xaml"); }); pinComposeToStart = new DelegateCommand((obj) => { SecondaryTiles.CreateComposeTile(); pinComposeToStart.RaiseCanExecuteChanged(); }, (obj) => !SecondaryTiles.ComposeTileIsCreated()); addAccount = new DelegateCommand((obj) => Navigate(Uris.LoginPage)); editFilters = new DelegateCommand((obj) => { DataTransfer.cFilter = Config.GlobalFilter; DataTransfer.IsGlobalFilter = true; Navigate(Uris.Filters); }); saveCredentials = new DelegateCommand((obj) => { AuthPair PocketPair = null; AuthPair InstapaperPair = null; if (!string.IsNullOrWhiteSpace(PocketUser)) { BarText = "Verifying credentials..."; IsLoading = true; PocketPair = new AuthPair { User = PocketUser, Password = PocketPassword }; var service = new PocketService { UserName = PocketPair.User, Password = PocketPair.Password }; service.CheckCredentials((valid, response) => { if (valid) { MessageService.ShowLightNotification("Credentials saved."); Config.ReadLaterCredentials.Pocket = PocketPair; Config.ReadLaterCredentials = Config.ReadLaterCredentials; } else { IsLoading = false; MessageService.ShowError("Invalid Pocket credentials"); } }); } else { Config.ReadLaterCredentials.Pocket = null; Config.ReadLaterCredentials = Config.ReadLaterCredentials; } if (!string.IsNullOrWhiteSpace(InstapaperUser)) { BarText = "Verifying credentials..."; IsLoading = true; InstapaperPair = new AuthPair { User = InstapaperUser, Password = InstapaperPassword }; var service = new InstapaperService { UserName = InstapaperPair.User, Password = InstapaperPair.Password }; service.CheckCredentials((valid, response) => { if (valid) { MessageService.ShowLightNotification("Credentials saved."); Config.ReadLaterCredentials.Instapaper = InstapaperPair; Config.ReadLaterCredentials = Config.ReadLaterCredentials; } else { IsLoading = false; MessageService.ShowError("Invalid Instapaper credentials."); } }); } else { Config.ReadLaterCredentials.Pocket = null; Config.ReadLaterCredentials = Config.ReadLaterCredentials; } }); }