IClientChannelSink-Schnittstelle
Stellt erforderliche Funktionen und Eigenschaften für Clientchannelempfänger bereit.
Namespace: System.Runtime.Remoting.Channels
Assembly: mscorlib (in mscorlib.dll)
Syntax
'Declaration
<ComVisibleAttribute(True)> _
Public Interface IClientChannelSink
Inherits IChannelSinkBase
'Usage
Dim instance As IClientChannelSink
[ComVisibleAttribute(true)]
public interface IClientChannelSink : IChannelSinkBase
[ComVisibleAttribute(true)]
public interface class IClientChannelSink : IChannelSinkBase
/** @attribute ComVisibleAttribute(true) */
public interface IClientChannelSink extends IChannelSinkBase
ComVisibleAttribute(true)
public interface IClientChannelSink extends IChannelSinkBase
Hinweise
Channelempfänger stellen einen Plug-In-Punkt bereit, der den Zugriff auf die zugrunde liegenden, über den Channel übermittelten Meldungen sowie auf den Stream ermöglicht, der vom Übertragungsmechanismus zum Senden von Meldungen an ein Remoteobjekt verwendet wird. Channelempfänger sind in einer Kette von Channelempfängerprovidern miteinander verknüpft, und alle Channelmeldungen werden über diese Kette von Empfängern geleitet, bevor sie serialisiert und übertragen werden.
Beispiel
Im folgenden Codebeispiel wird eine Implementierung der IClientChannelSink-Schnittstelle veranschaulicht.
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;
}
}
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;
}
};
import System.*;
import System.Collections.*;
import System.IO.*;
import System.Runtime.Remoting.Channels.*;
import System.Runtime.Remoting.Messaging.*;
import System.Security.Permissions.*;
/** @attribute SecurityPermission(SecurityAction.Demand, Flags = SecurityPermissionFlag.Infrastructure)
*/
public class ClientSink extends BaseChannelSinkWithProperties
implements IClientChannelSink
{
// This class inherits from BaseChannelSinkWithPropertes
// to get an implementation of IChannelSinkBase.
// The next sink in the chain.
private IClientChannelSink nextSink;
/** @property
*/
public IClientChannelSink get_NextChannelSink()
{
return nextSink;
}//get_NextChannelSink
public Stream GetRequestStream(IMessage message,
ITransportHeaders requestHeaders)
{
// Get the request stream from the next sink in the chain.
return nextSink.GetRequestStream(message, requestHeaders);
} //GetRequestStream
public void ProcessMessage(IMessage message, ITransportHeaders requestHeaders,
Stream requestStream, /** @ref */ ITransportHeaders responseHeaders,
/** @ref */ Stream responseStream)
{
// Print the request message properties.
Console.WriteLine("---- Message from the client ----");
IDictionary dictionary = message.get_Properties();
Object key = null;
IEnumerator objEnum = dictionary.get_Keys().GetEnumerator();
while (objEnum.MoveNext()) {
key = objEnum.get_Current();
Console.WriteLine("{0} = {1}", key, dictionary.get_Item(key));
}
Console.WriteLine("---------------------------------");
// Hand off to the next sink in the chain.
nextSink.ProcessMessage(message, requestHeaders, requestStream,
responseHeaders, responseStream);
} //ProcessMessage
// For synchronous remoting, it is not necessary to implement this method.
public void AsyncProcessRequest(IClientChannelSinkStack sinkStack,
IMessage message, ITransportHeaders requestHeaders, Stream requestStream)
throws NotImplementedException
{
throw new NotImplementedException();
} //AsyncProcessRequest
public void AsyncProcessResponse(IClientResponseChannelSinkStack sinkStack,
Object state, ITransportHeaders responseHeaders, Stream responseStream)
throws NotImplementedException
{
throw new NotImplementedException();
} //AsyncProcessResponse
// Constructor
public ClientSink(IClientChannelSink sink)
{
if (sink == null) {
throw new ArgumentNullException("sink");
}
nextSink = sink;
} //ClientSink
} //ClientSink
Ein Beispiel für die entsprechende Implementierung eines Clientsenkenanbieters finden Sie in der Dokumentation der IClientChannelSinkProvider-Schnittstelle.
Plattformen
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 unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.
Versionsinformationen
.NET Framework
Unterstützt in: 2.0, 1.1, 1.0
Siehe auch
Referenz
IClientChannelSink-Member
System.Runtime.Remoting.Channels-Namespace