OptionalReliableSession 클래스

정의

신뢰할 수 있는 세션이 선택 사항인 미리 정의된 바인딩 중 하나를 사용하는 경우 신뢰할 수 있는 세션을 사용할 수 있는지 여부에 대한 편리한 액세스를 제공합니다.

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

예제

다음 예제에서는 신뢰할 수 있는 새 세션을 만들고, 해당 세션의 기본값에 액세스하고, 변경하는 방법을 보여줍니다.

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

설명

신뢰할 수 있는 세션을 사용하도록 설정하는 기능은 시스템에서 제공하는 세 가지 바인딩과 함께 제공됩니다. 신뢰할 수 있는 세션은 다음과 같습니다.

생성자

OptionalReliableSession()

OptionalReliableSession 클래스의 새 인스턴스를 초기화합니다.

OptionalReliableSession(ReliableSessionBindingElement)

신뢰할 수 있는 세션 바인딩 요소에서 OptionalReliableSession 클래스의 새 인스턴스를 초기화합니다.

속성

Enabled

신뢰할 수 있는 세션을 사용할 수 있는지 여부를 나타내는 값을 가져오거나 설정합니다.

InactivityTimeout

서비스를 닫기 전에 서비스가 비활성 상태로 유지될 수 있는 시간 간격을 가져오거나 설정합니다.

(다음에서 상속됨 ReliableSession)
Ordered

메시지 배달 시 메시지를 보낸 순서를 유지할지 여부를 나타내는 값을 가져오거나 설정합니다.

(다음에서 상속됨 ReliableSession)

메서드

Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

적용 대상