Share via


IClientChannelSink Antarmuka

Definisi

Menyediakan fungsi dan properti yang diperlukan untuk sink saluran klien.

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
Turunan
Atribut
Penerapan

Contoh

Contoh kode berikut mengilustrasikan implementasi IClientChannelSink antarmuka.

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 Lihat dokumentasi antarmuka untuk contoh implementasi penyedia sink klien yang sesuai.

Keterangan

Sink saluran menyediakan titik plug-in yang memungkinkan akses ke pesan yang mendasar yang mengalir melalui saluran serta aliran yang digunakan oleh mekanisme transportasi untuk mengirim pesan ke objek jarak jauh. Sink saluran ditautkan bersama dalam rantai penyedia sink saluran dan semua pesan saluran mengalir melalui rantai sink ini sebelum diserialisasikan dan diangkut.

Properti

NextChannelSink

Mendapatkan sink saluran klien berikutnya di rantai sink klien.

Properties

Mendapatkan kamus di mana properti di sink dapat diakses.

(Diperoleh dari IChannelSinkBase)

Metode

AsyncProcessRequest(IClientChannelSinkStack, IMessage, ITransportHeaders, Stream)

Meminta pemrosesan asinkron dari panggilan metode pada sink saat ini.

AsyncProcessResponse(IClientResponseChannelSinkStack, Object, ITransportHeaders, Stream)

Meminta pemrosesan asinkron respons terhadap panggilan metode pada sink saat ini.

GetRequestStream(IMessage, ITransportHeaders)

Mengembalikan ke Stream tempat pesan yang disediakan akan diserialisasikan.

ProcessMessage(IMessage, ITransportHeaders, Stream, ITransportHeaders, Stream)

Meminta pemrosesan pesan dari sink saat ini.

Berlaku untuk

Lihat juga