Exemplo n.º 1
0
 /// <summary>
 /// Invoked when the <see cref="LoadUserOperation"/> completes.
 /// Use this event handler to switch from the "loading UI" you created in <see cref="InitializeRootVisual"/> to the "application UI".
 /// </summary>
 private void Application_UserLoaded(LoadUserOperation operation)
 {
     if (operation.HasError)
     {
         ErrorWindow.CreateNew(operation.Error);
         operation.MarkErrorAsHandled();
     }
 }
Exemplo n.º 2
0
 private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
 {
     // If the app is running outside of the debugger then report the exception using a ChildWindow control.
     if (!System.Diagnostics.Debugger.IsAttached)
     {
         // NOTE: This will allow the application to continue running after an exception has been thrown but not handled.
         // For production applications this error handling should be replaced with something that will report the error to the website and stop the application.
         e.Handled = true;
         ErrorWindow.CreateNew(e.ExceptionObject);
     }
 }
Exemplo n.º 3
0
 private void LogoutButton_Click(object sender, RoutedEventArgs e)
 {
     WebContext.Current.Authentication.Logout(logoutOperation =>
     {
         if (logoutOperation.HasError)
         {
             ErrorWindow.CreateNew(logoutOperation.Error);
             logoutOperation.MarkErrorAsHandled();
         }
     }, /* userState */ null);
 }
 /// <summary>
 /// Completion handler for a <see cref="LoginOperation"/>.
 /// If operation succeeds, it closes the window.
 /// If it has an error, it displays an <see cref="ErrorWindow"/> and marks the error as handled.
 /// If it was not canceled, but login failed, it must have been because credentials were incorrect so a validation error is added to notify the user.
 /// </summary>
 private void LoginOperation_Completed(LoginOperation loginOperation)
 {
     if (loginOperation.LoginSuccess)
     {
         this.parentWindow.DialogResult = true;
     }
     else if (loginOperation.HasError)
     {
         ErrorWindow.CreateNew(loginOperation.Error);
         loginOperation.MarkErrorAsHandled();
     }
     else if (!loginOperation.IsCanceled)
     {
         this.loginInfo.ValidationErrors.Add(new ValidationResult(ErrorResources.ErrorBadUserNameOrPassword, new string[] { "UserName", "Password" }));
     }
 }