다음을 통해 공유


LogoutOperation 클래스

AuthenticationService에 대한 Logout 작업에서 반환된 작업 형식입니다.

네임스페이스: System.ServiceModel.DomainServices.Client.ApplicationServices
어셈블리: system.servicemodel.domainservices.client.dll의 System.ServiceModel.DomainServices.Client

사용법

‘사용 방법
Dim instance As LogoutOperation

구문

‘선언
Public NotInheritable Class LogoutOperation
    Inherits AuthenticationOperation
public sealed class LogoutOperation : AuthenticationOperation
public ref class LogoutOperation sealed : public AuthenticationOperation
public final class LogoutOperation extends AuthenticationOperation
public final class LogoutOperation extends AuthenticationOperation

예제

다음 예제에서는 LogoutOperation 개체를 매개 변수로 사용하는 콜백 메서드를 포함하는 Logout 메서드 호출을 보여 줍니다.

Protected Overrides Sub OnNavigatedTo(ByVal e As System.Windows.Navigation.NavigationEventArgs)
    SetControlVisibility(WebContext.Current.User.IsAuthenticated)
End Sub

Private Sub LoginButton_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
    Dim lp As LoginParameters = New LoginParameters(UserName.Text, Password.Password)
    WebContext.Current.Authentication.Login(lp, AddressOf Me.LoginOperation_Completed, Nothing)
    LoginButton.IsEnabled = False
    LoginResult.Text = ""
End Sub

Private Sub LoginOperation_Completed(ByVal lo As LoginOperation)
    If (lo.HasError) Then
        LoginResult.Text = lo.Error.Message
        LoginResult.Visibility = System.Windows.Visibility.Visible
        lo.MarkErrorAsHandled()
    ElseIf (lo.LoginSuccess = False) Then
        LoginResult.Text = "Login failed. Please check user name and password."
        LoginResult.Visibility = System.Windows.Visibility.Visible
    ElseIf (lo.LoginSuccess = True) Then
        SetControlVisibility(True)
    End If
    LoginButton.IsEnabled = True
End Sub

Private Sub SetControlVisibility(ByVal isAuthenticated As Boolean)
    If (isAuthenticated) Then
        LoginBorder.Visibility = System.Windows.Visibility.Collapsed
        WelcomeText.Text = "Welcome " + WebContext.Current.User.Name
        WelcomeText.Visibility = System.Windows.Visibility.Visible
        LogoutButton.Visibility = System.Windows.Visibility.Visible
    Else
        LoginBorder.Visibility = System.Windows.Visibility.Visible
        WelcomeText.Visibility = System.Windows.Visibility.Collapsed
        LogoutButton.Visibility = System.Windows.Visibility.Collapsed
    End If
End Sub

Private Sub LogoutButton_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
    WebContext.Current.Authentication.Logout(AddressOf Me.LogoutOperation_Completed, Nothing)
End Sub

Private Sub LogoutOperation_Completed(ByVal lo As LogoutOperation)
    If (Not (lo.HasError)) Then
        SetControlVisibility(False)
    Else
        Dim ew As ErrorWindow = New ErrorWindow("Logout failed.", "Please try logging out again.")
        ew.Show()
        lo.MarkErrorAsHandled()
    End If
End Sub
protected override void OnNavigatedTo(NavigationEventArgs e)
{
    SetControlVisibility(WebContext.Current.User.IsAuthenticated);
}

private void LoginButton_Click(object sender, RoutedEventArgs e)
{
    LoginParameters lp = new LoginParameters(UserName.Text, Password.Password);
    WebContext.Current.Authentication.Login(lp, this.LoginOperation_Completed, null);
    LoginButton.IsEnabled = false;
    LoginResult.Text = "";
}

private void LoginOperation_Completed(LoginOperation lo)
{
    if (lo.HasError)
    {
        LoginResult.Text = lo.Error.Message;
        LoginResult.Visibility = System.Windows.Visibility.Visible;
        lo.MarkErrorAsHandled();
    }
    else if (lo.LoginSuccess == false)
    {
        LoginResult.Text = "Login failed. Please check user name and password.";
        LoginResult.Visibility = System.Windows.Visibility.Visible;
    }
    else if (lo.LoginSuccess == true)
    {
        SetControlVisibility(true);
    }
    LoginButton.IsEnabled = true;
}

private void SetControlVisibility(bool isAuthenticated)
{
    if (isAuthenticated)
    {
        LoginBorder.Visibility = System.Windows.Visibility.Collapsed;
        WelcomeText.Text = "Welcome " + WebContext.Current.User.Name;
        WelcomeText.Visibility = System.Windows.Visibility.Visible;
        LogoutButton.Visibility = System.Windows.Visibility.Visible;
    }
    else
    {
        LoginBorder.Visibility = System.Windows.Visibility.Visible;
        WelcomeText.Visibility = System.Windows.Visibility.Collapsed;
        LogoutButton.Visibility = System.Windows.Visibility.Collapsed;
    }
}

private void LogoutButton_Click(object sender, RoutedEventArgs e)
{
    WebContext.Current.Authentication.Logout(this.LogoutOperation_Completed, null);
}

private void LogoutOperation_Completed(LogoutOperation lo)
{

    if (!lo.HasError)
    {
        SetControlVisibility(false);
    }
    else
    {
        ErrorWindow ew = new ErrorWindow("Logout failed.", "Please try logging out again.");
        ew.Show();
        lo.MarkErrorAsHandled();
    }
}

상속 계층

System.Object
   System.ServiceModel.DomainServices.Client.OperationBase
     System.ServiceModel.DomainServices.Client.ApplicationServices.AuthenticationOperation
      System.ServiceModel.DomainServices.Client.ApplicationServices.LogoutOperation

스레드 보안

이 형식의 모든 public static(Visual Basic의 경우 Shared) 멤버는 스레드로부터 안전합니다. 모든 인스턴스 멤버는 스레드로부터 안전하지 않을 수 있습니다.

플랫폼

개발 플랫폼

Windows XP Home Edition, Windows XP Professional, Windows Server 2003 , Windows Server 2008 및 Windows 2000

대상 플랫폼

Change History

참고 항목

참조

LogoutOperation 멤버
System.ServiceModel.DomainServices.Client.ApplicationServices 네임스페이스