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

注釈

信頼できるセッションを有効にする機能は、システムが提供するバインディングのうちの 3 つを備えています。 信頼できるセッションは、次のようになります。

コンストラクター

OptionalReliableSession()

OptionalReliableSession クラスの新しいインスタンスを初期化します。

OptionalReliableSession(ReliableSessionBindingElement)

信頼できるセッション バインド要素から、OptionalReliableSession クラスの新しいインスタンスを初期化します。

プロパティ

Enabled

信頼できるセッションが有効かどうかを示す値を取得または設定します。

InactivityTimeout

サービスが非アクティブになってから終了するまでの時間を取得または設定します。

(継承元 ReliableSession)
Ordered

メッセージが送信された順序をメッセージ配信で維持する必要があるかどうかを示す値を取得または設定します。

(継承元 ReliableSession)

メソッド

Equals(Object)

指定されたオブジェクトが現在のオブジェクトと等しいかどうかを判断します。

(継承元 Object)
GetHashCode()

既定のハッシュ関数として機能します。

(継承元 Object)
GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
MemberwiseClone()

現在の Object の簡易コピーを作成します。

(継承元 Object)
ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)

適用対象