ClientSponsor クラス
アセンブリ: mscorlib (mscorlib.dll 内)
構文<ComVisibleAttribute(True)> _ Public Class ClientSponsor Inherits MarshalByRefObject Implements ISponsor
解説有効期間スポンサの現在の実装は、更新時間として必要な値を TimeSpan を指定することにより、オブジェクトのスポンサとして使用できます。
メモ |
|---|
| このクラスは、リンク確認要求と継承確認要求をクラス レベルで行います。直前の呼び出し元または派生クラスにインフラストラクチャ アクセス許可がない場合、SecurityException がスローされます。セキュリティ要求の詳細については、「リンク確認要求」および「継承確認要求」を参照してください。 |
使用例クラスでアクティブ化されるリモート オブジェクトの有効期間を延長する ClientSponsor クラスの例を次に示します。
Imports System Imports System.Runtime.Remoting Imports System.Runtime.Remoting.Channels Imports System.Runtime.Remoting.Channels.Tcp Imports System.Runtime.Remoting.Lifetime Namespace RemotingSamples Class HelloClient Shared Sub Main() ' Register a channel. Dim myChannel As New TcpChannel() ChannelServices.RegisterChannel(myChannel) RemotingConfiguration.RegisterActivatedClientType( _ GetType(HelloService), "tcp://localhost:8085") ' Get the remote object. Dim myService As New HelloService() ' Get a sponsor for renewal of time. Dim mySponsor As New ClientSponsor() ' Register the service with sponsor. mySponsor.Register(myService) ' Set renewaltime. mySponsor.RenewalTime = TimeSpan.FromMinutes(2) ' Renew the lease. Dim myLease As ILease = CType(mySponsor.InitializeLifetimeService(), ILease) Dim myTime As TimeSpan = mySponsor.Renewal(myLease) Console.WriteLine("Renewed time in minutes is " & myTime.Minutes) ' Call the remote method. Console.WriteLine(myService.HelloMethod("World")) ' Unregister the channel. mySponsor.Unregister(myService) mySponsor.Close() End Sub 'Main End Class 'HelloClient End Namespace 'RemotingSamples
using System; using System.Runtime.Remoting; using System.Runtime.Remoting.Channels; using System.Runtime.Remoting.Channels.Tcp; using System.Runtime.Remoting.Lifetime; namespace RemotingSamples { class HelloClient { static void Main() { // Register a channel. TcpChannel myChannel = new TcpChannel (); ChannelServices.RegisterChannel(myChannel); RemotingConfiguration.RegisterActivatedClientType( typeof(HelloService),"tcp://localhost:8085/"); // Get the remote object. HelloService myService = new HelloService(); // Get a sponsor for renewal of time. ClientSponsor mySponsor = new ClientSponsor(); // Register the service with sponsor. mySponsor.Register(myService); // Set renewaltime. mySponsor.RenewalTime = TimeSpan.FromMinutes(2); // Renew the lease. ILease myLease = (ILease)mySponsor.InitializeLifetimeService(); TimeSpan myTime = mySponsor.Renewal(myLease); Console.WriteLine("Renewed time in minutes is " + myTime.Minutes.ToString()); // Call the remote method. Console.WriteLine(myService.HelloMethod("World")); // Unregister the channel. mySponsor.Unregister(myService); mySponsor.Close(); } } }
#using <system.dll> #using <system.runtime.remoting.dll> #using <ClientSponsor_Share.dll> using namespace System; using namespace System::Runtime::Remoting; using namespace System::Runtime::Remoting::Channels; using namespace System::Runtime::Remoting::Channels::Tcp; using namespace System::Runtime::Remoting::Lifetime; int main() { // Register a channel. TcpChannel^ myChannel = gcnew TcpChannel; ChannelServices::RegisterChannel( myChannel ); RemotingConfiguration::RegisterActivatedClientType( RemotingSamples::HelloService::typeid, "tcp://localhost:8085/" ); // Get the remote Object*. RemotingSamples::HelloService ^ myService = gcnew RemotingSamples::HelloService; // Get a sponsor for renewal of time. ClientSponsor^ mySponsor = gcnew ClientSponsor; // Register the service with sponsor. mySponsor->Register( myService ); // Set renewaltime. mySponsor->RenewalTime = TimeSpan::FromMinutes( 2 ); // Renew the lease. ILease^ myLease = dynamic_cast<ILease^>(mySponsor->InitializeLifetimeService()); TimeSpan myTime = mySponsor->Renewal( myLease ); Console::WriteLine( "Renewed time in minutes is {0}", myTime.Minutes ); // Call the remote method. Console::WriteLine( myService->HelloMethod( "World" ) ); // Unregister the channel. mySponsor->Unregister( myService ); mySponsor->Close(); }
.NET Framework のセキュリティ- SecurityPermission (インフラストラクチャ コードを操作するために必要なアクセス許可)。要求値 : SecurityAction.LinkDemand; アクセス許可値 : SecurityPermissionFlag.Infrastructure
- SecurityPermission (インフラストラクチャ コードを操作するために必要なアクセス許可)。要求値 : SecurityAction.InheritanceDemand; アクセス許可値 : SecurityPermissionFlag.Infrastructure
継承階層System.MarshalByRefObject
System.Runtime.Remoting.Lifetime.ClientSponsor
スレッド セーフ
プラットフォームWindows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
バージョン情報
参照ClientSponsor コンストラクタ ()
アセンブリ: mscorlib (mscorlib.dll 内)
構文
解説2 分ごとに更新する必要がある場合に、スポンサの対象オブジェクトの有効期間が延長される既定の時間間隔。更新時間の詳細については、LifetimeServices.RenewOnCallTime プロパティのトピックを参照してください。
プラットフォームWindows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
バージョン情報
参照ClientSponsor コンストラクタ (TimeSpan)
アセンブリ: mscorlib (mscorlib.dll 内)
構文
プラットフォームWindows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
バージョン情報
参照ClientSponsor コンストラクタ
オーバーロードの一覧| 名前 | 説明 |
|---|---|
| ClientSponsor () | ClientSponsor クラスの新しいインスタンスを既定値で初期化します。 |
| ClientSponsor (TimeSpan) | スポンサの対象オブジェクトの更新時間を使用して、ClientSponsor クラスの新しいインスタンスを初期化します。 |
参照ClientSponsor プロパティ
ClientSponsor メソッド
パブリック メソッド| 名前 | 説明 | |
|---|---|---|
| Close | 現在の ClientSponsor で登録されているリスト オブジェクトを空にします。 |
| CreateObjRef | リモート オブジェクトとの通信に使用するプロキシの生成に必要な情報をすべて格納しているオブジェクトを作成します。 ( MarshalByRefObject から継承されます。) |
| Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 ( Object から継承されます。) |
| GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 ( Object から継承されます。) |
| GetLifetimeService | 対象のインスタンスの有効期間ポリシーを制御する、現在の有効期間サービス オブジェクトを取得します。 ( MarshalByRefObject から継承されます。) |
| GetType | 現在のインスタンスの Type を取得します。 ( Object から継承されます。) |
| InitializeLifetimeService | オーバーライドされます。 現在のオブジェクトのリースを使用して、ClientSponsor の新しいインスタンスを初期化します。 |
| ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。) |
| Register | 指定した MarshalByRefObject をスポンサシップとして登録します。 |
| Renewal | 指定したオブジェクトのリースを更新するスポンサ クライアントを要求します。 |
| ToString | 現在の Object を表す String を返します。 ( Object から継承されます。) |
| Unregister | 現在の ClientSponsor がスポンサであるオブジェクトのリストから、指定した MarshalByRefObject の登録を解除します。 |
プロテクト メソッド| 名前 | 説明 | |
|---|---|---|
| Finalize | オーバーライドされます。 ガベージ コレクタがクリアする前に、現在の ClientSponsor のリソースを解放します。 |
| MemberwiseClone | オーバーロードされます。 ( MarshalByRefObject から継承されます。) |
参照ClientSponsor メンバ
ClientSponsor データ型で公開されるメンバを以下の表に示します。
パブリック コンストラクタ
パブリック プロパティ
パブリック メソッド| 名前 | 説明 | |
|---|---|---|
| Close | 現在の ClientSponsor で登録されているリスト オブジェクトを空にします。 |
| CreateObjRef | リモート オブジェクトとの通信に使用するプロキシの生成に必要な情報をすべて格納しているオブジェクトを作成します。 (MarshalByRefObject から継承されます。) |
| Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 (Object から継承されます。) |
| GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 (Object から継承されます。) |
| GetLifetimeService | 対象のインスタンスの有効期間ポリシーを制御する、現在の有効期間サービス オブジェクトを取得します。 (MarshalByRefObject から継承されます。) |
| GetType | 現在のインスタンスの Type を取得します。 (Object から継承されます。) |
| InitializeLifetimeService | オーバーライドされます。 現在のオブジェクトのリースを使用して、ClientSponsor の新しいインスタンスを初期化します。 |
| ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。) |
| Register | 指定した MarshalByRefObject をスポンサシップとして登録します。 |
| Renewal | 指定したオブジェクトのリースを更新するスポンサ クライアントを要求します。 |
| ToString | 現在の Object を表す String を返します。 (Object から継承されます。) |
| Unregister | 現在の ClientSponsor がスポンサであるオブジェクトのリストから、指定した MarshalByRefObject の登録を解除します。 |
プロテクト メソッド| 名前 | 説明 | |
|---|---|---|
| Finalize | オーバーライドされます。 ガベージ コレクタがクリアする前に、現在の ClientSponsor のリソースを解放します。 |
| MemberwiseClone | オーバーロードされます。 ( MarshalByRefObject から継承されます。) |
参照- ClientSponsorのページへのリンク
.gif)