IClientChannelSink Interface
Definição
Fornece as propriedades e as funções necessárias para coletores de canal do cliente.Provides required functions and properties for client channel sinks.
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
- Derivado
- Atributos
- Implementações
Exemplos
O exemplo de código a seguir ilustra uma implementação da IClientChannelSink interface.The following code example illustrates an implementation of the IClientChannelSink interface.
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;
using System.Security.Permissions;
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
{
[SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.Infrastructure)]
get
{
return(nextSink);
}
}
[SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.Infrastructure)]
public Stream GetRequestStream (IMessage message, ITransportHeaders requestHeaders)
{
// Get the request stream from the next sink in the chain.
return( nextSink.GetRequestStream(message, requestHeaders) );
}
[SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.Infrastructure)]
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.
[SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.Infrastructure)]
public void AsyncProcessRequest (IClientChannelSinkStack sinkStack,
IMessage message,
ITransportHeaders requestHeaders,
Stream requestStream)
{
throw new NotImplementedException();
}
[SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.Infrastructure)]
public void AsyncProcessResponse (IClientResponseChannelSinkStack sinkStack,
Object state,
ITransportHeaders responseHeaders,
Stream responseStream)
{
throw new NotImplementedException();
}
// Constructor
[SecurityPermission(SecurityAction.LinkDemand)]
public ClientSink (IClientChannelSink sink) {
if (sink == null) throw new ArgumentNullException("sink");
nextSink = sink;
}
}
Consulte a IClientChannelSinkProvider documentação da interface para obter um exemplo da implementação do provedor de coletor do cliente correspondente.See the IClientChannelSinkProvider interface documentation for an example of the corresponding client sink provider implementation.
Comentários
Os coletores de canal fornecem um ponto de plug-in que permite o acesso às mensagens subjacentes que fluem pelo canal, bem como o fluxo usado pelo mecanismo de transporte para enviar mensagens a um objeto remoto.Channel sinks provide a plug-in point that allows access to the underlying messages flowing through the channel as well as the stream used by the transport mechanism to send messages to a remote object. Os coletores de canal são vinculados juntos em uma cadeia de provedores de coletor de canal e todas as mensagens de canal fluem por essa cadeia de coletores antes de serem serializados e transportados.Channel sinks are linked together in a chain of channel sink providers and all channel messages flow through this chain of sinks before they are serialized and transported.
Propriedades
| NextChannelSink |
Obtém o próximo coletor de canal do cliente na cadeia de coletor do cliente.Gets the next client channel sink in the client sink chain. |
| Properties |
Obtém um dicionário por meio do qual propriedades no coletor podem ser acessadas.Gets a dictionary through which properties on the sink can be accessed. (Herdado de IChannelSinkBase) |
Métodos
| AsyncProcessRequest(IClientChannelSinkStack, IMessage, ITransportHeaders, Stream) |
Solicita o processamento assíncrono de uma chamada de método no coletor atual.Requests asynchronous processing of a method call on the current sink. |
| AsyncProcessResponse(IClientResponseChannelSinkStack, Object, ITransportHeaders, Stream) |
Solicita o processamento assíncrono de uma resposta a uma chamada de método no coletor atual.Requests asynchronous processing of a response to a method call on the current sink. |
| GetRequestStream(IMessage, ITransportHeaders) |
Retorna o Stream no qual a mensagem fornecida deve ser serializada.Returns the Stream onto which the provided message is to be serialized. |
| ProcessMessage(IMessage, ITransportHeaders, Stream, ITransportHeaders, Stream) |
Solicita o processamento de mensagens do coletor atual.Requests message processing from the current sink. |