OptionalReliableSession Clase

Definición

Proporciona el acceso adecuado a si una sesión confiable está habilitada cuando se usa uno de los enlaces predefinidos donde es opcional.Provides convenient access to whether a reliable session is enabled when using one of the predefined bindings where it is optional.

public ref class OptionalReliableSession : System::ServiceModel::ReliableSession
public class OptionalReliableSession : System.ServiceModel.ReliableSession
type OptionalReliableSession = class
    inherit ReliableSession
Public Class OptionalReliableSession
Inherits ReliableSession
Herencia
OptionalReliableSession

Ejemplos

El ejemplo siguiente muestra cómo crear una nueva sesión confiable, tener acceso y cambiar los valores predeterminados de esa sesión.The following example shows how to create a new reliable session, access and change the default values of that session.

private void Run()
{
    WSHttpBinding b = new WSHttpBinding();
    b.Name = "HttpOrderedReliableSessionBinding";

    // Get a reference to the OptionalreliableSession object of the
    // binding and set its properties to new values.
    OptionalReliableSession myReliableSession = b.ReliableSession;
    myReliableSession.Enabled = true; // The default is false.
    myReliableSession.Ordered = false; // The default is true.
    myReliableSession.InactivityTimeout =
        new TimeSpan(0, 15, 0); // The default is 10 minutes.
    // Create a URI for the service's base address.
    Uri baseAddress = new Uri("http://localhost:8008/Calculator");

    // Create a service host.
    ServiceHost sh = new ServiceHost(typeof(Calculator), baseAddress);

    // Optional: Print out the binding information.
    PrintBindingInfo(b);
    // Create a URI for an endpoint, then add a service endpoint using the
    // binding with the latered OptionalReliableSession settings.
    sh.AddServiceEndpoint(typeof(ICalculator), b, "ReliableCalculator");
    sh.Open();

    Console.WriteLine("Listening...");
    Console.ReadLine();
    sh.Close();
}

private void PrintBindingInfo(WSHttpBinding b)
{
    Console.WriteLine(b.Name);
    Console.WriteLine("Enabled: {0}", b.ReliableSession.Enabled);
    Console.WriteLine("Ordered: {0}", b.ReliableSession.Ordered);
    Console.WriteLine("Inactivity in Minutes: {0}",
        b.ReliableSession.InactivityTimeout.TotalMinutes);
}
Private Sub Run()
    Dim b As New WSHttpBinding()
    b.Name = "HttpOrderedReliableSessionBinding"

    ' Get a reference to the OptionalreliableSession object of the 
    ' binding and set its properties to new values.
    Dim myReliableSession As OptionalReliableSession = b.ReliableSession
    myReliableSession.Enabled = True ' The default is false.
    myReliableSession.Ordered = False ' The default is true. 
    myReliableSession.InactivityTimeout = New TimeSpan(0, 15, 0)
    ' The default is 10 minutes.
    ' Create a URI for the service's base address.
    Dim baseAddress As New Uri("http://localhost:8008/Calculator")

    ' Create a service host.
    Dim sh As New ServiceHost(GetType(Calculator), baseAddress)

    ' Optional: Print out the binding information. 
    PrintBindingInfo(b)
    ' Create a URI for an endpoint, then add a service endpoint using the
    ' binding with the latered OptionalReliableSession settings.
    sh.AddServiceEndpoint(GetType(ICalculator), b, "ReliableCalculator")
    sh.Open()

    Console.WriteLine("Listening...")
    Console.ReadLine()
    sh.Close()
End Sub

Private Sub PrintBindingInfo(ByVal b As WSHttpBinding)
    Console.WriteLine(b.Name)
    Console.WriteLine("Enabled: {0}", b.ReliableSession.Enabled)
    Console.WriteLine("Ordered: {0}", b.ReliableSession.Ordered)
    Console.WriteLine("Inactivity in Minutes: {0}", b.ReliableSession.InactivityTimeout.TotalMinutes)

End Sub

Comentarios

La posibilidad de habilitar una sesión confiable se consigue con tres de los enlaces proporcionados por el sistema.The ability to enable a reliable session is provided with three of the system-provided bindings. Una sesión confiable es:A reliable session is:

Constructores

OptionalReliableSession()

Inicializa una nueva instancia de la clase OptionalReliableSession.Initializes a new instance of the OptionalReliableSession class.

OptionalReliableSession(ReliableSessionBindingElement)

Inicializa una nueva instancia de la clase OptionalReliableSession a partir de un elemento de enlace de la sesión confiable.Initializes a new instance of the OptionalReliableSession class from a reliable session binding element.

Propiedades

Enabled

Obtiene o establece un valor que indica si se ha habilitado la sesión confiable.Gets or sets a value that indicates whether the reliable session is enabled.

InactivityTimeout

Obtiene o establece un intervalo de tiempo durante el que un servicio puede permanecer inactivo antes de cerrarse.Gets or sets an interval of time that a service can remain inactive before closing.

(Heredado de ReliableSession)
Ordered

Obtiene o establece un valor que indica si la entrega del mensaje debe conservar el orden en el que se envían los mensajes.Gets or sets a value that indicates whether message delivery must preserve the order in which messages are sent.

(Heredado de ReliableSession)

Métodos

Equals(Object)

Determina si el objeto especificado es igual que el objeto actual.Determines whether the specified object is equal to the current object.

(Heredado de Object)
GetHashCode()

Sirve como la función hash predeterminada.Serves as the default hash function.

(Heredado de Object)
GetType()

Obtiene el Type de la instancia actual.Gets the Type of the current instance.

(Heredado de Object)
MemberwiseClone()

Crea una copia superficial del Object actual.Creates a shallow copy of the current Object.

(Heredado de Object)
ToString()

Devuelve una cadena que representa el objeto actual.Returns a string that represents the current object.

(Heredado de Object)

Se aplica a