BaseChannelSinkWithProperties Classe

Definição

Fornece uma implementação base para coletores de canal que desejam expor uma interface de dicionário a suas propriedades.Provides a base implementation for channel sinks that want to expose a dictionary interface to their properties.

public ref class BaseChannelSinkWithProperties abstract : System::Runtime::Remoting::Channels::BaseChannelObjectWithProperties
[System.Runtime.InteropServices.ComVisible(true)]
[System.Security.SecurityCritical]
public abstract class BaseChannelSinkWithProperties : System.Runtime.Remoting.Channels.BaseChannelObjectWithProperties
type BaseChannelSinkWithProperties = class
    inherit BaseChannelObjectWithProperties
Public MustInherit Class BaseChannelSinkWithProperties
Inherits BaseChannelObjectWithProperties
Herança
BaseChannelSinkWithProperties
Atributos

Exemplos

[SecurityPermission(SecurityAction::Demand, Flags = SecurityPermissionFlag::Infrastructure)]
private ref class MyClientFormatterChannelSink: public BaseChannelSinkWithProperties, public IClientChannelSink, public IMessageSink
{
private:
   IClientChannelSink^ nextClientSink;
   IMessageSink^ nextMessageSink;

public:
   MyClientFormatterChannelSink()
      : nextClientSink( nullptr ), nextMessageSink( nullptr )
   {}

   MyClientFormatterChannelSink( IClientChannelSink^ nextSink, IMessageSink^ nextMsgSink )
      : BaseChannelSinkWithProperties()
   {
      nextClientSink = nextSink;
      nextMessageSink = nextMsgSink;
   }

    virtual void ProcessMessage( IMessage^ message, ITransportHeaders^ requestHeaders, Stream^ requestStream, [Out]ITransportHeaders^% responseHeaders, [Out]Stream^% responseStream )
    {
      nextClientSink->ProcessMessage( message, requestHeaders, requestStream, responseHeaders, responseStream );
    }



   virtual void AsyncProcessRequest( IClientChannelSinkStack^ sinkStack, IMessage^ msg, ITransportHeaders^ headers, Stream^ myStream )
   {
      sinkStack->Push( this, nullptr );
      nextClientSink->AsyncProcessRequest( sinkStack, msg, headers, myStream );
   }

   virtual void AsyncProcessResponse( IClientResponseChannelSinkStack^ sinkStack, Object^ /*state*/, ITransportHeaders^ headers, Stream^ myStream )
   {
      sinkStack->AsyncProcessResponse( headers, myStream );
   }

   virtual Stream^ GetRequestStream( IMessage^ /*msg*/, ITransportHeaders^ /*headers*/ )
   {
      return nullptr;
   }


   property IClientChannelSink^ NextChannelSink 
   {
      virtual IClientChannelSink^ get()
      {
         return nextClientSink;
      }

   }

   property IMessageSink^ NextSink 
   {
      virtual IMessageSink^ get()
      {
         return nextMessageSink;
      }

   }

   virtual IMessageCtrl^ AsyncProcessMessage( IMessage^ /*msg*/, IMessageSink^ /*replySink*/ )
   {
      return nullptr;
   }

   virtual IMessage^ SyncProcessMessage( IMessage^ msg )
   {
      return nextMessageSink->SyncProcessMessage( msg );
   }


   property Object^ Item [Object^]
   {
      virtual Object^ get( Object^ key ) override
      {
          if ( key == MyKey::typeid )
                  return this;

         return nullptr;
      }

      virtual void set( Object^ /*value*/, Object^ /*key*/ ) override
      {
         throw gcnew NotSupportedException;
      }

   }

   property ICollection^ Keys 
   {
      virtual ICollection^ get() override
      {
         ArrayList^ myKeys = gcnew ArrayList( 1 );
         myKeys->Add( MyKey::typeid );
         return myKeys;
      }

   }

};



[SecurityPermission(SecurityAction.Demand, Flags = SecurityPermissionFlag.Infrastructure)]
internal class MyClientFormatterChannelSink :
         BaseChannelSinkWithProperties, IClientChannelSink, IMessageSink
{
   private IClientChannelSink nextClientSink=null;
   private IMessageSink nextMessageSink = null;

   public MyClientFormatterChannelSink(IClientChannelSink nextSink,
                                       IMessageSink nextMsgSink) : base()
   {
      nextClientSink = nextSink;
      nextMessageSink = nextMsgSink;
   }

   public void ProcessMessage(IMessage msg,
         ITransportHeaders requestHeaders, Stream requestStream,
         out ITransportHeaders responseHeaders, out Stream responseStream)
   {
      nextClientSink.ProcessMessage(msg, requestHeaders, requestStream,
               out responseHeaders, out responseStream);
   }

   public void AsyncProcessRequest(IClientChannelSinkStack sinkStack,
                  IMessage msg, ITransportHeaders headers, Stream myStream)
   {
      sinkStack.Push(this, null);
      nextClientSink.AsyncProcessRequest(sinkStack,msg,headers,myStream);
   }

   public void AsyncProcessResponse(IClientResponseChannelSinkStack sinkStack,
         Object state, ITransportHeaders headers, Stream myStream)
   {
      sinkStack.AsyncProcessResponse(headers, myStream);
   }

   public Stream GetRequestStream(IMessage msg,ITransportHeaders headers)
   {
      return null;
   }

   public IClientChannelSink NextChannelSink
   {
      get
      {
         return nextClientSink;
      }
   }

   public IMessageSink NextSink
   {
      get
      {
         return nextMessageSink;
      }
   }

   public IMessageCtrl AsyncProcessMessage(IMessage msg,
                                                IMessageSink replySink)
   {
      return null;
   }

   public IMessage SyncProcessMessage(IMessage msg)
   {
      return nextMessageSink.SyncProcessMessage(msg);
   }

   public override Object this[Object key]
   {
      get
      {
         if (key == typeof(MyKey))
            return this;
         return null;
      }
      set
      {
         throw new NotSupportedException();
      }
   }
   public override ICollection Keys
   {
      get
      {
         ArrayList myKeys = new ArrayList(1);
         myKeys.Add(typeof(MyKey));
         return myKeys;
      }
   }
}
public class MyKey
{
}
<PermissionSet(SecurityAction.Demand, Name:="FullTrust")> _
Friend Class MyClientFormatterChannelSink
   Inherits BaseChannelSinkWithProperties
   Implements IClientChannelSink, IMessageSink
   Private nextClientSink As IClientChannelSink = Nothing
   Private nextMessageSink As IMessageSink = Nothing

   Public Sub New(nextSink As IClientChannelSink, nextMsgSink As IMessageSink)
      MyBase.New()
      nextClientSink = nextSink
      nextMessageSink = nextMsgSink
   End Sub

   Public Sub ProcessMessage(msg As IMessage, requestHeaders As ITransportHeaders, _
               requestStream As Stream, ByRef responseHeaders As ITransportHeaders, _
               ByRef responseStream As Stream) _
               Implements IClientChannelSink.ProcessMessage
      nextClientSink.ProcessMessage(msg, requestHeaders, requestStream, _
                                    responseHeaders, responseStream)
   End Sub

   Public Sub AsyncProcessRequest(sinkStack As IClientChannelSinkStack, _
            msg As IMessage, headers As ITransportHeaders, myStream As Stream) _
            Implements IClientChannelSink.AsyncProcessRequest
      sinkStack.Push(Me, Nothing)
      nextClientSink.AsyncProcessRequest(sinkStack, msg, headers, myStream)
   End Sub

   Public Sub AsyncProcessResponse(sinkStack As IClientResponseChannelSinkStack, _
            state As Object, headers As ITransportHeaders, myStream As Stream) _
            Implements IClientChannelSink.AsyncProcessResponse
      sinkStack.AsyncProcessResponse(headers, myStream)
   End Sub

   Public Function GetRequestStream(msg As IMessage, headers As ITransportHeaders) As Stream _
         Implements IClientChannelSink.GetRequestStream
      Return Nothing
   End Function 'GetRequestStream

   Public ReadOnly Property NextChannelSink() As IClientChannelSink _
         Implements IClientChannelSink.NextChannelSink
      Get
         Return nextClientSink
      End Get
   End Property

   Public ReadOnly Property NextSink() As IMessageSink _
         Implements IMessageSink.NextSink
      Get
         Return nextMessageSink
      End Get
   End Property

   Public Overrides ReadOnly Property Properties() As Collections.IDictionary _
            Implements IClientChannelSink.Properties
      Get
      End Get
   End Property

   Public Function AsyncProcessMessage(msg As IMessage, replySink As IMessageSink) As IMessageCtrl _
            Implements IMessageSink.AsyncProcessMessage
      Return Nothing
   End Function 'AsyncProcessMessage

   Public Function SyncProcessMessage(msg As IMessage) As IMessage _
            Implements IMessageSink.SyncProcessMessage
      Return nextMessageSink.SyncProcessMessage(msg)
   End Function 'SyncProcessMessage

   Default Public Overrides Property Item(key As Object) As Object
      Get
         If key Is GetType(MyKey) Then
            Return Me
         End If
         Return Nothing
      End Get
      Set
         Throw New NotSupportedException()
      End Set
   End Property

   Public Overrides ReadOnly Property Keys() As ICollection
      Get
         Dim myKeys As New ArrayList(0)
         myKeys.Add(GetType(MyKey))
         Return myKeys
      End Get
   End Property
End Class

Public Class MyKey
End Class

Comentários

Os coletores de canal fornecem um ponto de plug-in que permite o acesso às mensagens subjacentes que estão fluindo 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 that are flowing through the channel as well as the stream that is 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 que a mensagem seja serializada e transportada.Channel sinks are linked together in a chain of channel sink providers, and all channel messages flow through this chain of sinks before the message is serialized and transported.

Essa classe faz uma demanda de link e uma demanda de herança no nível de classe.This class makes a link demand and an inheritance demand at the class level. Um SecurityException é gerado quando o chamador imediato ou a classe derivada não tem permissão de infraestrutura.A SecurityException is thrown when either the immediate caller or the derived class does not have infrastructure permission. Para obter detalhes sobre as demandas de segurança, consulte demandas de link e demandas de herança.For details about security demands, see Link Demands and Inheritance Demands.

Notas aos Implementadores

Ao herdar do BaseChannelSinkWithProperties, você deve implementar a Keys Propriedade e a Item[Object] propriedade.When you inherit from BaseChannelSinkWithProperties, you must implement the Keys property and the Item[Object] property.

Construtores

BaseChannelSinkWithProperties()

Inicializa uma nova instância da classe BaseChannelSinkWithProperties.Initializes a new instance of the BaseChannelSinkWithProperties class.

Propriedades

Count

Obtém o número de propriedades associadas ao objeto de canal.Gets the number of properties associated with the channel object.

(Herdado de BaseChannelObjectWithProperties)
IsFixedSize

Obtém um valor que indica se o número de propriedades que podem ser inseridas no canal de objeto é fixo.Gets a value that indicates whether the number of properties that can be entered into the channel object is fixed.

(Herdado de BaseChannelObjectWithProperties)
IsReadOnly

Obtém um valor que indica se a coleção de propriedades no objeto de canal é somente leitura.Gets a value that indicates whether the collection of properties in the channel object is read-only.

(Herdado de BaseChannelObjectWithProperties)
IsSynchronized

Obtém um valor que indica se o dicionário de propriedades de objeto de canal é sincronizado.Gets a value that indicates whether the dictionary of channel object properties is synchronized.

(Herdado de BaseChannelObjectWithProperties)
Item[Object]

Quando substituída em uma classe derivada, obtém ou define a propriedade associada à chave especificada.When overridden in a derived class, gets or sets the property that is associated with the specified key.

(Herdado de BaseChannelObjectWithProperties)
Keys

Quando substituída em uma classe derivada, obtém um ICollection de chaves ao qual as propriedades de objeto de canal estão associadas.When overridden in a derived class, gets a ICollection of keys that the channel object properties are associated with.

(Herdado de BaseChannelObjectWithProperties)
Properties

Obtém um IDictionary das propriedades de canal associadas ao objeto de canal.Gets a IDictionary of the channel properties associated with the channel object.

(Herdado de BaseChannelObjectWithProperties)
SyncRoot

Obtém um objeto usado para sincronizar o acesso ao BaseChannelObjectWithProperties.Gets an object that is used to synchronize access to the BaseChannelObjectWithProperties.

(Herdado de BaseChannelObjectWithProperties)
Values

Obtém um ICollection dos valores das propriedades associadas ao objeto de canal.Gets a ICollection of the values of the properties associated with the channel object.

(Herdado de BaseChannelObjectWithProperties)

Métodos

Add(Object, Object)

Gera uma NotSupportedException.Throws a NotSupportedException.

(Herdado de BaseChannelObjectWithProperties)
Clear()

Gera uma NotSupportedException.Throws a NotSupportedException.

(Herdado de BaseChannelObjectWithProperties)
Contains(Object)

Retorna um valor que indica se o objeto de canal contém uma propriedade associada à chave especificada.Returns a value that indicates whether the channel object contains a property that is associated with the specified key.

(Herdado de BaseChannelObjectWithProperties)
CopyTo(Array, Int32)

Gera uma NotSupportedException.Throws a NotSupportedException.

(Herdado de BaseChannelObjectWithProperties)
Equals(Object)

Determina se o objeto especificado é igual ao objeto atual.Determines whether the specified object is equal to the current object.

(Herdado de Object)
GetEnumerator()

Retorna um IDictionaryEnumerator que enumera em todas as propriedades associadas ao objeto de canal.Returns a IDictionaryEnumerator that enumerates over all the properties associated with the channel object.

(Herdado de BaseChannelObjectWithProperties)
GetHashCode()

Serve como a função de hash padrão.Serves as the default hash function.

(Herdado de Object)
GetType()

Obtém o Type da instância atual.Gets the Type of the current instance.

(Herdado de Object)
MemberwiseClone()

Cria uma cópia superficial do Object atual.Creates a shallow copy of the current Object.

(Herdado de Object)
Remove(Object)

Gera uma NotSupportedException.Throws a NotSupportedException.

(Herdado de BaseChannelObjectWithProperties)
ToString()

Retorna uma cadeia de caracteres que representa o objeto atual.Returns a string that represents the current object.

(Herdado de Object)

Implantações explícitas de interface

IEnumerable.GetEnumerator()

Retorna um IEnumerator que enumera em todas as propriedades associadas ao objeto de canal.Returns a IEnumerator that enumerates over all the properties that are associated with the channel object.

(Herdado de BaseChannelObjectWithProperties)

Métodos de Extensão

Cast<TResult>(IEnumerable)

Converte os elementos de um IEnumerable para o tipo especificado.Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable)

Filtra os elementos de um IEnumerable com base em um tipo especificado.Filters the elements of an IEnumerable based on a specified type.

AsParallel(IEnumerable)

Habilita a paralelização de uma consulta.Enables parallelization of a query.

AsQueryable(IEnumerable)

Converte um IEnumerable em um IQueryable.Converts an IEnumerable to an IQueryable.

Segurança

SecurityPermission
Para operar com o código de infraestrutura.For operating with infrastructure code. Valor de demanda InheritanceDemand:; Valor da permissão:InfrastructureDemand value: InheritanceDemand; Permission Value: Infrastructure

Aplica-se a