void RefreshFeed(bool force = false) { HandleError(() => { // Try to get the access token from out isolated storage accessToken = Storage.AccessTokenStorage.RetrieveAccessToken(); if (accessToken != null) { // If we already have the access token in the storage, just load the current feed. ToogleSignInState(true); Dispatcher.BeginInvoke(() => { (this.ApplicationBar.Buttons[1] as ApplicationBarIconButton).IsEnabled = true; (this.ApplicationBar.MenuItems[0] as ApplicationBarMenuItem).IsEnabled = true; }); LoadStream(force); } else { Authorize(() => { Dispatcher.BeginInvoke(() => { ToogleSignInState(true); (this.ApplicationBar.Buttons[1] as ApplicationBarIconButton).IsEnabled = true; (this.ApplicationBar.MenuItems[0] as ApplicationBarMenuItem).IsEnabled = true; LoadStream(force); }); }); } }); }
private void SignOutButton_Click(object sender, EventArgs e) { HandleError(() => { if (this.data.IsSignedIn) { (this.ApplicationBar.MenuItems[0] as ApplicationBarMenuItem).IsEnabled = false; (this.ApplicationBar.Buttons[1] as ApplicationBarIconButton).IsEnabled = false; Storage.AccessTokenStorage.ClearAccessToken(); accessToken = null; data.Reset(); ToogleSignInState(false); } }); }
private void Authorize(Action afterAuthorize) { HandleError(() => { // We don't have the access token in the storage, start the OAuth autorization process. var auth = new Yammer.ApiAuthorization(AuthBrowser); auth.AfterBrowsingComplete += new Yammer.ApiAuthorization.AfterBrowsingCompleteHandler(auth_AfterBrowsingComplete); auth.BeforeBrowsingBegin += new Yammer.ApiAuthorization.BeforeBrowsingBeginHandler(auth_BeforeBrowsingBegin); auth.BeginAuthorization(at => { // Now that the authorization process is completed, save the access token for future uses and load the current feed. accessToken = at; Storage.AccessTokenStorage.SaveAccessToken(at); afterAuthorize(); }); }); }