IClientChannelSink 介面
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
提供用戶端通道匯所需的功能與特性。
public interface class IClientChannelSink : System::Runtime::Remoting::Channels::IChannelSinkBase
public interface IClientChannelSink : System.Runtime.Remoting.Channels.IChannelSinkBase
[System.Runtime.InteropServices.ComVisible(true)]
public interface IClientChannelSink : System.Runtime.Remoting.Channels.IChannelSinkBase
type IClientChannelSink = interface
interface IChannelSinkBase
[<System.Runtime.InteropServices.ComVisible(true)>]
type IClientChannelSink = interface
interface IChannelSinkBase
Public Interface IClientChannelSink
Implements IChannelSinkBase
- 衍生
- 屬性
- 實作
範例
以下程式碼範例說明了該 IClientChannelSink 介面的實作。
using namespace System::Runtime::InteropServices;
using namespace System;
using namespace System::Collections;
using namespace System::IO;
using namespace System::Runtime::Remoting::Channels;
using namespace System::Runtime::Remoting::Messaging;
[System::Security::Permissions::PermissionSet(System::Security::
Permissions::SecurityAction::Demand, Name = "FullTrust")]
public ref class ClientSink: public BaseChannelSinkWithProperties, public IClientChannelSink
{
private:
// This class inherits from BaseChannelSinkWithPropertes
// to get an implementation of IChannelSinkBase.
// The next sink in the chain.
IClientChannelSink^ nextSink;
public:
property IClientChannelSink^ NextChannelSink
{
virtual IClientChannelSink^ get()
{
return (nextSink);
}
}
virtual Stream^ GetRequestStream( IMessage^ message, ITransportHeaders^ requestHeaders )
{
// Get the request stream from the next sink in the chain.
return (nextSink->GetRequestStream( message, requestHeaders ));
}
virtual void ProcessMessage( IMessage^ message, ITransportHeaders^ requestHeaders, Stream^ requestStream, [Out]ITransportHeaders^% responseHeaders, [Out]Stream^% responseStream )
{
// Print the request message properties.
Console::WriteLine( "---- Message from the client ----" );
IDictionary^ dictionary = message->Properties;
IEnumerator^ myEnum = dictionary->Keys->GetEnumerator();
while ( myEnum->MoveNext() )
{
Object^ key = safe_cast<Object^>(myEnum->Current);
Console::WriteLine( "{0} = {1}", key, dictionary[ key ] );
}
Console::WriteLine( "---------------------------------" );
// Hand off to the next sink in the chain.
nextSink->ProcessMessage( message, requestHeaders, requestStream, responseHeaders, responseStream );
}
// For synchronous remoting, it is not necessary to implement this method.
virtual void AsyncProcessRequest( IClientChannelSinkStack^ /*sinkStack*/, IMessage^ /*message*/, ITransportHeaders^ /*requestHeaders*/, Stream^ /*requestStream*/ )
{
throw gcnew NotImplementedException;
}
virtual void AsyncProcessResponse( IClientResponseChannelSinkStack^ /*sinkStack*/, Object^ /*state*/, ITransportHeaders^ /*responseHeaders*/, Stream^ /*responseStream*/ )
{
throw gcnew NotImplementedException;
}
property System::Collections::IDictionary^ Properties
{
virtual System::Collections::IDictionary^ get() override
{
return (dynamic_cast<BaseChannelSinkWithProperties^>(this))->Properties;
}
}
// Constructor
ClientSink( IClientChannelSink^ sink )
{
if ( sink == nullptr )
throw gcnew ArgumentNullException( "sink" );
nextSink = sink;
}
};
using System;
using System.Collections;
using System.IO;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Messaging;
public class ClientSink : BaseChannelSinkWithProperties, IClientChannelSink
{
// This class inherits from BaseChannelSinkWithPropertes
// to get an implementation of IChannelSinkBase.
// The next sink in the chain.
private IClientChannelSink nextSink;
public IClientChannelSink NextChannelSink
{
get
{
return(nextSink);
}
}
public Stream GetRequestStream (IMessage message, ITransportHeaders requestHeaders)
{
// Get the request stream from the next sink in the chain.
return( nextSink.GetRequestStream(message, requestHeaders) );
}
public void ProcessMessage (IMessage message,
ITransportHeaders requestHeaders,
Stream requestStream,
out ITransportHeaders responseHeaders,
out Stream responseStream)
{
// Print the request message properties.
Console.WriteLine("---- Message from the client ----");
IDictionary dictionary = message.Properties;
foreach (Object key in dictionary.Keys)
{
Console.WriteLine("{0} = {1}", key, dictionary[key]);
}
Console.WriteLine("---------------------------------");
// Hand off to the next sink in the chain.
nextSink.ProcessMessage(message, requestHeaders, requestStream, out responseHeaders, out responseStream);
}
// For synchronous remoting, it is not necessary to implement this method.
public void AsyncProcessRequest (IClientChannelSinkStack sinkStack,
IMessage message,
ITransportHeaders requestHeaders,
Stream requestStream)
{
throw new NotImplementedException();
}
public void AsyncProcessResponse (IClientResponseChannelSinkStack sinkStack,
Object state,
ITransportHeaders responseHeaders,
Stream responseStream)
{
throw new NotImplementedException();
}
// Constructor
public ClientSink (IClientChannelSink sink) {
if (sink == null) throw new ArgumentNullException("sink");
nextSink = sink;
}
}
請參閱 IClientChannelSinkProvider 介面文件以了解對應用戶端匯提供者實作的範例。
備註
通道匯提供一個外掛點,允許存取通道中流經的底層訊息,以及傳輸機制用來向遠端物件傳送訊息的串流。 通道匯被串連成一條通道匯流提供者鏈,所有通道訊息在序列化並傳輸前都會流經這條匯鏈。
屬性
| 名稱 | Description |
|---|---|
| NextChannelSink |
它會取得下一個客戶端通道的匯入。 |
| Properties |
會取得一本字典,透過字典來存取水槽上的屬性。 (繼承來源 IChannelSinkBase) |
方法
| 名稱 | Description |
|---|---|
| AsyncProcessRequest(IClientChannelSinkStack, IMessage, ITransportHeaders, Stream) |
請求在目前匯入埠上進行方法呼叫的非同步處理。 |
| AsyncProcessResponse(IClientResponseChannelSinkStack, Object, ITransportHeaders, Stream) |
請求對目前匯入埠的方法呼叫進行非同步處理。 |
| GetRequestStream(IMessage, ITransportHeaders) |
回傳要序列化訊息的 。Stream |
| ProcessMessage(IMessage, ITransportHeaders, Stream, ITransportHeaders, Stream) |
請求從目前匯流器處理訊息。 |