チャネル フックが待機する URI を追加します。
Public Overridable Sub AddHookChannelUri( _
ByVal channelUri As String _) Implements IChannelReceiverHook.AddHookChannelUri
[C#]
public virtual void AddHookChannelUri(stringchannelUri);
[C++]
public: virtual void AddHookChannelUri(String* channelUri);
[JScript]
public function AddHookChannelUri(
channelUri : String);
パラメータ
- channelUri
チャネル フックが待機しているチャネル URI。
実装
IChannelReceiverHook.AddHookChannelUri
解説
メモ クライアント コードでは、 AddHookChannelUri メソッドを直接呼び出さないでください。
使用例
[Visual Basic, C#, C++] AddHookChannelUri メソッドの機能を次の例に示します。クライアント コードでこのメソッドを直接呼び出してはいけないため、この例では、 HttpChannel クラスの動作を模倣するクラスでのメソッドの実装を示します。
Class CustomChannel
Inherits BaseChannelWithProperties
Implements IChannelReceiverHook, IChannelReceiver, IChannel, IChannelSender
Public Sub AddHookChannelUri(ByVal channelUri As String) _
Implements IChannelReceiverHook.AddHookChannelUri
If Not (channelUri Is Nothing) Then
Dim uris As String() = dataStore.ChannelUris
' This implementation only allows one URI to be hooked in.
If uris Is Nothing Then
Dim newUris(1) As String
newUris(0) = channelUri
dataStore.ChannelUris = newUris
wantsListen = False
Else
Dim msg As String
msg = "This channel is already listening for data, and " + _
"can't be hooked into at this stage."
Throw New System.Runtime.Remoting.RemotingException(msg)
End If
End If
End Sub
' The rest of CustomChannel's implementation.
[C#]
class CustomChannel : BaseChannelWithProperties, IChannelReceiverHook,
IChannelReceiver, IChannel, IChannelSender {
public void AddHookChannelUri(string channelUri) {
if (channelUri != null) {
string [] uris = dataStore.ChannelUris;
// This implementation only allows one URI to be hooked in.
if (uris == null) {
string [] newUris = new string[1];
newUris[0] = channelUri;
dataStore.ChannelUris = newUris;
wantsToListen = false;
} else {
string msg = "This channel is already listening for " +
"data, and can't be hooked into at this stage.";
throw new System.Runtime.Remoting.RemotingException(msg);
}
}
}
// The rest of CustomChannel's implementation.
[C++]
__gc class CustomChannel : public BaseChannelWithProperties, public IChannelReceiverHook,
public IChannelReceiver, public IChannel, public IChannelSender
{
public:
void AddHookChannelUri(String* channelUri)
{
if (channelUri != 0)
{
String* uris __gc[] = dataStore->ChannelUris;
// This implementation only allows one URI to be hooked in.
if (uris == 0)
{
String* newUris __gc[] = new String*[1];
newUris->Item[0] = channelUri;
dataStore->ChannelUris = newUris;
wantsToListen = false;
}
else
{
String* msg = S"This channel is already listening for data, and can't be hooked into at this stage.";
throw new System::Runtime::Remoting::RemotingException(msg);
}
}
}
// The rest of CustomChannel's implementation.
[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ
.NET Framework セキュリティ:
- 直前の呼び出し元の完全信頼。このメンバは、部分的に信頼されているコードから使用することはできません。詳細の参照先 : 部分信頼コードからのライブラリの使用
参照
HttpChannel クラス | HttpChannel メンバ | System.Runtime.Remoting.Channels.Http 名前空間