LogoutOperation Class
[WCF RIA Services Version 1 Service Pack 2 is compatible with either .NET framework 4 or .NET Framework 4.5, and with either Silverlight 4 or Silverlight 5.]
Operation type returned from Logout operations on AuthenticationService.
Inheritance Hierarchy
System.Object
System.ServiceModel.DomainServices.Client.OperationBase
System.ServiceModel.DomainServices.Client.ApplicationServices.AuthenticationOperation
System.ServiceModel.DomainServices.Client.ApplicationServices.LogoutOperation
Namespace: System.ServiceModel.DomainServices.Client.ApplicationServices
Assembly: System.ServiceModel.DomainServices.Client (in System.ServiceModel.DomainServices.Client.dll)
Syntax
'Declaration
Public NotInheritable Class LogoutOperation _
Inherits AuthenticationOperation
'Usage
Dim instance As LogoutOperation
public sealed class LogoutOperation : AuthenticationOperation
public ref class LogoutOperation sealed : public AuthenticationOperation
[<SealedAttribute>]
type LogoutOperation =
class
inherit AuthenticationOperation
end
public final class LogoutOperation extends AuthenticationOperation
The LogoutOperation type exposes the following members.
Properties
Name | Description | |
---|---|---|
AsyncResult | Gets the asynchronous result returned from BeginCore. (Inherited from AuthenticationOperation.) | |
CanCancel | Gets a value that indicates whether this OperationBase is currently in a state that enables it to be canceled. (Inherited from OperationBase.) | |
Error | Gets the operation error if the operation failed. (Inherited from OperationBase.) | |
HasError | Gets a value that indicates whether the operation failed. (Inherited from OperationBase.) | |
IsCanceled | Gets a value that indicates whether this operation has been canceled. (Inherited from OperationBase.) | |
IsComplete | Gets a value that indicates whether this operation has completed. (Inherited from OperationBase.) | |
IsErrorHandled | Gets or sets a value that indicates whether the operation error has been handled. (Inherited from OperationBase.) | |
Result | Gets the result as an AuthenticationResult. (Inherited from AuthenticationOperation.) | |
Service | Gets the service this operation will use to implement Begin, Cancel, and End. (Inherited from AuthenticationOperation.) | |
SupportsCancellation | Gets a value that indicates whether the operation supports cancellation. (Inherited from AuthenticationOperation.) | |
User | Gets the user principal. (Inherited from AuthenticationOperation.) | |
UserState | Gets the optional user state for this operation. (Inherited from OperationBase.) |
Top
Methods
Name | Description | |
---|---|---|
BeginCore | Invokes the corresponding Begin method in the underlying asynchronous result implementation. (Inherited from AuthenticationOperation.) | |
Cancel | Cancels the operation. (Inherited from OperationBase.) | |
CancelCore | When overridden in a derived class, provides the logic to cancel the operation. (Inherited from OperationBase.) | |
Complete(Exception) | Completes a failed operation with the specified error. (Inherited from OperationBase.) | |
Complete(Object) | Completes a successful operation with the specified result. (Inherited from OperationBase.) | |
EndCore | Invokes the corresponding End method in the underlying asynchronous result implementation. (Inherited from AuthenticationOperation.) | |
Equals | (Inherited from Object.) | |
Finalize | (Inherited from Object.) | |
GetHashCode | (Inherited from Object.) | |
GetType | (Inherited from Object.) | |
InvokeCompleteAction | Invokes the completion callback. (Inherited from OperationBase.) | |
MarkErrorAsHandled | Specifies that an error encountered in an operation is handled. (Inherited from OperationBase.) | |
MemberwiseClone | (Inherited from Object.) | |
OnPropertyChanged | Called when the value of a property changes. (Inherited from OperationBase.) | |
RaiseCompletionPropertyChanges | Raises property changes after the operation has completed. (Inherited from AuthenticationOperation.) | |
RaisePropertyChanged | Raises the System#ComponentModel#INotifyPropertyChanged#PropertyChanged() event. (Inherited from OperationBase.) | |
ToString | (Inherited from Object.) |
Top
Events
Name | Description | |
---|---|---|
Completed | Occurs when the operation completes. (Inherited from OperationBase.) |
Top
Explicit Interface Implementations
Name | Description | |
---|---|---|
INotifyPropertyChanged.PropertyChanged | Occurs when a property value changes. (Inherited from OperationBase.) |
Top
Examples
The following example shows a call to the Logout method with callback method that accepts a LogoutOperation object as a parameter.
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();
}
}
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
See Also
Reference
System.ServiceModel.DomainServices.Client.ApplicationServices Namespace