protected virtual Task HandleActivation(WebAccountProviderActivatedEventArgs args) { return(Task.CompletedTask); }
private void OnWebAccountProvider(WebAccountProviderActivatedEventArgs args) { try { Frame rootFrame = Window.Current.Content as Frame; // Do not repeat app initialization when the Window already has content, // just ensure that the window is active if (rootFrame == null) { // Create a Frame to act as the navigation context and navigate to the first page rootFrame = new Frame(); // Set the default language rootFrame.Language = Windows.Globalization.ApplicationLanguages.Languages[0]; rootFrame.NavigationFailed += OnNavigationFailed; if (args.PreviousExecutionState == ApplicationExecutionState.Terminated) { //TODO: Load state from previously suspended application } // Place the frame in the current Window Window.Current.Content = rootFrame; } if (rootFrame.Content == null) { // When the navigation stack isn't restored navigate to the first page, // configuring the new page by passing required information as a navigation // parameter Trace.Log("DBG: rootFrame.Content is null"); Window.Current.Content = rootFrame; } var baseOperation = args.Operation; switch (baseOperation.Kind) { case WebAccountProviderOperationKind.RequestToken: { Trace.Log("DBG: operation.Option=RequestToken."); var requestOperation = baseOperation as WebAccountProviderRequestTokenOperation; rootFrame.Navigate(typeof(SampleUI.RequestTokenPage), requestOperation); } break; case WebAccountProviderOperationKind.AddAccount: { //the UI required to trigger this will only be available in the next Windows release Trace.Log("DBG: operation.Option=AddAccount."); var addAccountoperation = baseOperation as WebAccountProviderAddAccountOperation; rootFrame.Navigate(typeof(SampleUI.AddAccountPage), addAccountoperation); } break; case WebAccountProviderOperationKind.DeleteAccount: case WebAccountProviderOperationKind.ManageAccount: case WebAccountProviderOperationKind.RetrieveCookies: { //var manageAccountoperation = baseOperation as WebAccountProviderManageAccountOperation; //WebAccount accountToManage = manageAccountoperation.WebAccount; rootFrame.Navigate(typeof(SampleUI.ManageAccountPage), baseOperation); } break; default: Trace.Error("DBG: unkown UI operation kind"); base.OnActivated(args); break; } // Ensure the current window is active Window.Current.Activate(); } catch (Exception e) { Trace.LogException(e); throw e; } }