Freigeben über


BaseChannelObjectWithProperties-Klasse

Stellt eine Basisimplementierung eines Channelobjekts bereit, das den zugehörigen Eigenschaften eine Wörterbuchschnittstelle verfügbar macht.

Namespace: System.Runtime.Remoting.Channels
Assembly: mscorlib (in mscorlib.dll)

Syntax

'Declaration
<ComVisibleAttribute(True)> _
Public MustInherit Class BaseChannelObjectWithProperties
    Implements IDictionary, ICollection, IEnumerable
'Usage
Dim instance As BaseChannelObjectWithProperties
[ComVisibleAttribute(true)] 
public abstract class BaseChannelObjectWithProperties : IDictionary, ICollection, IEnumerable
[ComVisibleAttribute(true)] 
public ref class BaseChannelObjectWithProperties abstract : IDictionary, ICollection, IEnumerable
/** @attribute ComVisibleAttribute(true) */ 
public abstract class BaseChannelObjectWithProperties implements IDictionary, ICollection, 
    IEnumerable
ComVisibleAttribute(true) 
public abstract class BaseChannelObjectWithProperties implements IDictionary, ICollection, 
    IEnumerable

Hinweise

BaseChannelObjectWithProperties ist die Basisklasse für BaseChannelWithProperties und BaseChannelSinkWithProperties.

BaseChannelWithProperties und BaseChannelSinkWithProperties können als Basisklassen für Channels und Channelsenken verwendet werden, die benannte Eigenschaften bereitstellen.

BaseChannelObjectWithProperties behandelt die komplexe Aufgabe, ein Channelobjekt auf seine Eigenschaften abzufragen.

Diese Klasse führt einen Verknüpfungsaufruf und eine Vererbungsforderung auf der Klassenebene aus. Wenn der direkte Aufrufer bzw. die abgeleitete Klasse nicht über die Berechtigung für die Infrastruktur verfügen, wird eine SecurityException ausgelöst. Ausführliche Informationen über Sicherheitsforderungen finden Sie unter Verknüpfungsaufrufe und Vererbungsforderungen.

Hinweise für Erben Wenn Sie BaseChannelObjectWithProperties vererben, müssen Sie die Keys-Eigenschaft und die Item-Eigenschaft überschreiben.

Beispiel

<PermissionSet(SecurityAction.Demand, Name:="FullTrust")> _
Public Class LoggingServerChannelSinkProvider
   Implements IServerChannelSinkProvider 
   Private next2 As IServerChannelSinkProvider = Nothing
   
   Public Sub New(properties As IDictionary, providerData As ICollection)
   End Sub 'New
   
   Public Sub GetChannelData(channelData As IChannelDataStore) _ 
                               Implements IServerChannelSinkProvider.GetChannelData
   End Sub 'GetChannelData
   
   Public Function CreateSink(channel1 As IChannelReceiver) As IServerChannelSink _ 
                                     Implements IServerChannelSinkProvider.CreateSink
      Dim localNextSink As IServerChannelSink = Nothing
      If Not (next2 Is Nothing) Then
         localNextSink = next2.CreateSink(channel1)
      End If
      Return New LoggingServerChannelSink(localNextSink)
   End Function 'CreateSink
   
   Public Property [Next]() As IServerChannelSinkProvider Implements _ 
                                                     IServerChannelSinkProvider.Next
      Get
         Return next2
      End Get
      Set
         next2 = value
      End Set
   End Property
End Class 'LoggingServerChannelSinkProvider

<PermissionSet(SecurityAction.Demand, Name:="FullTrust")> _ 
Friend Class LoggingServerChannelSink
   Inherits BaseChannelObjectWithProperties
   Implements IServerChannelSink 
   Private nextSink2 As IServerChannelSink = Nothing
   Private bEnabled2 As Boolean = True
   
   Public Sub New(localNextSink As IServerChannelSink)
      MyBase.new()
      nextSink2 = localNextSink
   End Sub 'New
   
  Public Function ProcessMessage(   ByVal sinkStack As IServerChannelSinkStack, _
      ByVal requestMsg As IMessage, _
      ByVal requestHeaders As ITransportHeaders, _
      ByVal requestStream As Stream, _
      <Out> ByRef responseMsg As IMessage, _
      <Out> ByRef responseHeaders As ITransportHeaders, _
      <Out> ByRef responseStream As Stream _
   ) As ServerProcessing _ 
      Implements IServerChannelSink.ProcessMessage
      If bEnabled2 Then
         Console.WriteLine("----------Request Headers-----------")
         Console.WriteLine(CommonTransportKeys.IPAddress.ToString() + ":" + _ 
                              requestHeaders(CommonTransportKeys.IPAddress).ToString())
      Console.WriteLine(CommonTransportKeys.ConnectionId.ToString() + ":" + _ 
                              requestHeaders(CommonTransportKeys.ConnectionId).ToString())
      Console.WriteLine(CommonTransportKeys.RequestUri.ToString() + ":" + _ 
                              requestHeaders(CommonTransportKeys.RequestUri).ToString())
      End If
      sinkStack.Push(Me, Nothing)
      Dim processing As ServerProcessing = _ 
                                   nextSink2.ProcessMessage _ 
               (sinkStack, requestMsg, requestHeaders, requestStream, responseMsg, responseHeaders, responseStream)
      
      Select Case processing
         Case ServerProcessing.Complete
               sinkStack.Pop(Me)
         Case ServerProcessing.OneWay
               sinkStack.Pop(Me)
         Case ServerProcessing.Async
               sinkStack.Store(Me, Nothing)
      End Select
      Return processing
   End Function 'ProcessMessage
   
   Public Sub AsyncProcessResponse(sinkStack As IServerResponseChannelSinkStack, _ 
           state As Object, msg As IMessage, headers As ITransportHeaders, stream1 As Stream) _ 
                                    Implements IServerChannelSink.AsyncProcessResponse
      sinkStack.AsyncProcessResponse(msg, headers, stream1)
   End Sub 'AsyncProcessResponse
   
   Public Function GetResponseStream(sinkStack As IServerResponseChannelSinkStack, _ 
               state As Object, msg As IMessage, headers As ITransportHeaders) As Stream _ 
                                    Implements IServerChannelSink.GetResponseStream
      Return Nothing
   End Function 'GetResponseStream
   
   Public ReadOnly Property NextChannelSink() As IServerChannelSink _ 
                                       Implements IServerChannelSink.NextChannelSink
      Get
         Return nextSink2
      End Get
   End Property

   Public Overrides ReadOnly Property Properties() As Collections.IDictionary _ 
               Implements IServerChannelSink.Properties
      Get
     return nothing        
      End Get
   End Property
End Class 'LoggingServerChannelSink
   [PermissionSet(SecurityAction.Demand, Name="FullTrust")]
   public class LoggingServerChannelSinkProvider : IServerChannelSinkProvider
   {
      private IServerChannelSinkProvider next2 = null;
      public LoggingServerChannelSinkProvider(IDictionary properties, ICollection providerData)
      {
      }
      public void GetChannelData(IChannelDataStore channelData)
      {
      }
      public IServerChannelSink CreateSink(IChannelReceiver channel1)
      {
         IServerChannelSink localNextSink = null;
         if (next2 != null)
            localNextSink = next2.CreateSink(channel1);
         return new LoggingServerChannelSink(localNextSink);
      }
      public IServerChannelSinkProvider Next
      {
         get
         {
            return next2;
         }
         set
         {
            next2 = value;
         }
      }
   }
   [PermissionSet(SecurityAction.Demand, Name="FullTrust")]
   internal class LoggingServerChannelSink : BaseChannelObjectWithProperties, IServerChannelSink
   {
      private IServerChannelSink nextSink2 = null;
      private bool bEnabled2 = true;
      public LoggingServerChannelSink(IServerChannelSink localNextSink) : base()
      {
         nextSink2 = localNextSink;
      }
      public ServerProcessing ProcessMessage(   IServerChannelSinkStack sinkStack,
   IMessage requestMsg,
   ITransportHeaders requestHeaders,
   Stream requestStream,
   out IMessage responseMsg,
   out ITransportHeaders responseHeaders,
   out Stream responseStream
)
      {
         if (bEnabled2)
         {
            Console.WriteLine("----------Request Headers-----------");
            Console.WriteLine( CommonTransportKeys.IPAddress + ":" +
               requestHeaders[CommonTransportKeys.IPAddress]);
            Console.WriteLine( CommonTransportKeys.ConnectionId + ":" +
               requestHeaders[CommonTransportKeys.ConnectionId]);
            Console.WriteLine( CommonTransportKeys.RequestUri + ":" +
               requestHeaders[CommonTransportKeys.RequestUri]);

         }
         sinkStack.Push(this, null);
         ServerProcessing processing =
            nextSink2.ProcessMessage(sinkStack, requestMsg, requestHeaders, requestStream, out responseMsg,
            out responseHeaders, out responseStream);

         switch (processing)
         {
            case ServerProcessing.Complete :
            {
               sinkStack.Pop(this);
               break;
            }
            case ServerProcessing.OneWay:
            {
               sinkStack.Pop(this);
               break;
            }
            case ServerProcessing.Async:
            {
               sinkStack.Store(this, null);
               break;
            }
         }
         return processing;
      }
      public void AsyncProcessResponse(IServerResponseChannelSinkStack sinkStack, Object state,
         IMessage msg, ITransportHeaders headers, Stream stream1)
      {
         sinkStack.AsyncProcessResponse(msg, headers, stream1);
      }
      public Stream GetResponseStream(IServerResponseChannelSinkStack sinkStack, Object state,
         IMessage msg, ITransportHeaders headers)
      {
         return null;
      }
      public IServerChannelSink NextChannelSink
      {
         get
         {
            return nextSink2;
         }
      }
   }
   [PermissionSet(SecurityAction::Demand, Name="FullTrust")]
   private ref class LoggingServerChannelSink: public BaseChannelObjectWithProperties, public IServerChannelSink
   {
   private:
      IServerChannelSink^ nextSink2;
      bool bEnabled2;

   public:
      LoggingServerChannelSink()
         : nextSink2( nullptr ), bEnabled2( true )
      {}

      LoggingServerChannelSink( IServerChannelSink^ localNextSink )
         : BaseChannelObjectWithProperties()
      {
         nextSink2 = localNextSink;
      }

      virtual ServerProcessing ProcessMessage( IServerChannelSinkStack^ sinkStack, IMessage^ requestMsg, ITransportHeaders^ requestHeaders, Stream^ requestStream, [Out]IMessage^% responseMsg, [Out]ITransportHeaders^% responseHeaders, [Out]Stream^% responseStream ) = IServerChannelSink::ProcessMessage
      {
         if ( bEnabled2 )
         {
            Console::WriteLine( "----------Request Headers-----------" );
            
            Console::WriteLine( "{0}:{1}", CommonTransportKeys::IPAddress,
               requestHeaders[ CommonTransportKeys::IPAddress ] );
            Console::WriteLine( "{0}:{1}", CommonTransportKeys::ConnectionId,
               requestHeaders[ CommonTransportKeys::ConnectionId ] );
            Console::WriteLine( "{0}:{1}", CommonTransportKeys::RequestUri,
               requestHeaders[ CommonTransportKeys::RequestUri ] );
         }

         sinkStack->Push( this, nullptr );
         ServerProcessing processing = nextSink2->ProcessMessage( sinkStack, requestMsg, requestHeaders, requestStream, responseMsg, responseHeaders, responseStream );
         switch ( processing )
         {
            case ServerProcessing::Complete:
               sinkStack->Pop( this );
               break;

            case ServerProcessing::OneWay:
               sinkStack->Pop( this );
               break;

            case ServerProcessing::Async:
               sinkStack->Store( this, nullptr );
               break;
         }
         return processing;
      }

      virtual void AsyncProcessResponse( IServerResponseChannelSinkStack^ sinkStack, Object^ /*state*/, IMessage^ msg, ITransportHeaders^ headers, Stream^ stream1 )
      {
         sinkStack->AsyncProcessResponse( msg, headers, stream1 );
      }

      virtual Stream^ GetResponseStream( IServerResponseChannelSinkStack^ /*sinkStack*/, Object^ /*state*/, IMessage^ /*msg*/, ITransportHeaders^ /*headers*/ )
      {
         return nullptr;
      }

      property IServerChannelSink^ NextChannelSink 
      {
         virtual IServerChannelSink^ get()
         {
            return nextSink2;
         }
      }
   };

   [PermissionSet(SecurityAction::Demand, Name="FullTrust")]
   public ref class LoggingServerChannelSinkProvider: public IServerChannelSinkProvider
   {
   private:
      IServerChannelSinkProvider^ next2;

   public:
      LoggingServerChannelSinkProvider()
         : next2( nullptr )
      {}

      LoggingServerChannelSinkProvider( IDictionary^ /*properties*/, ICollection^ /*providerData*/ ){}

      virtual void GetChannelData( IChannelDataStore^ /*channelData*/ ){}

      virtual IServerChannelSink^ CreateSink( IChannelReceiver^ channel1 )
      {
         IServerChannelSink^ localNextSink = nullptr;
         if ( next2 != nullptr )
                  localNextSink = next2->CreateSink( channel1 );

         return gcnew LoggingServerChannelSink( localNextSink );
      }

      property IServerChannelSinkProvider^ Next 
      {
         virtual IServerChannelSinkProvider^ get()
         {
            return next2;
         }

         virtual void set( IServerChannelSinkProvider^ value )
         {
            next2 = value;
         }
      }
   };
}
public class LoggingServerChannelSinkProvider
    implements IServerChannelSinkProvider
{
    private IServerChannelSinkProvider next2 = null;

    public LoggingServerChannelSinkProvider(IDictionary properties,
        ICollection providerData)
    {
    } //LoggingServerChannelSinkProvider

    public void GetChannelData(IChannelDataStore channelData)
    {
    } //GetChannelData

    public IServerChannelSink CreateSink(IChannelReceiver channel1)
    {
        IServerChannelSink localNextSink = null;
        if (next2 != null) {
            localNextSink = next2.CreateSink(channel1);
        }
        return new LoggingServerChannelSink(localNextSink);
    } //CreateSink

    /** @property 
     */
    public IServerChannelSinkProvider get_Next()
    {
        return next2;
    } //get_Next

    /** @property 
     */
    public void set_Next(IServerChannelSinkProvider value)
    {
        next2 = value;
    } //set_Next
} //LoggingServerChannelSinkProvider

class LoggingServerChannelSink extends BaseChannelObjectWithProperties
   implements IServerChannelSink
{
    private IServerChannelSink nextSink2 = null;
    private boolean bEnabled2 = true;

    public LoggingServerChannelSink(IServerChannelSink localNextSink)
    {
        nextSink2 = localNextSink;
    } //LoggingServerChannelSink

    public ServerProcessing ProcessMessage(IServerChannelSinkStack sinkStack,
        IMessage requestMsg, ITransportHeaders requestHeaders,
        Stream requestStream,
        /**@ref
         */IMessage responseMsg,
        /**@ref
         */ITransportHeaders responseHeaders,
        /**@ref
         */Stream responseStream)
    {
        if (bEnabled2) {
            Console.WriteLine("----------Request Headers-----------");
            Console.WriteLine(CommonTransportKeys.IPAddress + ":"
                + requestHeaders.get_Item(CommonTransportKeys.IPAddress));
            Console.WriteLine(CommonTransportKeys.ConnectionId + ":"
                + requestHeaders.get_Item(CommonTransportKeys.ConnectionId));

            Console.WriteLine(CommonTransportKeys.RequestUri + ":"
                + requestHeaders.get_Item(CommonTransportKeys.RequestUri));
        }

        sinkStack.Push(this, null);
        ServerProcessing processing =
            nextSink2.ProcessMessage(sinkStack, requestMsg, requestHeaders,
            requestStream, responseMsg, responseHeaders, responseStream);
        switch (processing) {
            case ServerProcessing.Complete :
                sinkStack.Pop(this);
                break;
            case ServerProcessing.OneWay :
                sinkStack.Pop(this);
                break;
            case ServerProcessing.Async :
                sinkStack.Store(this, null);
                break;
        }
        return processing;
    } //ProcessMessage

    public void AsyncProcessResponse(IServerResponseChannelSinkStack sinkStack,
        Object state, IMessage msg, ITransportHeaders headers, Stream stream1)
    {
        sinkStack.AsyncProcessResponse(msg, headers, stream1);
    } //AsyncProcessResponse

    public Stream GetResponseStream(IServerResponseChannelSinkStack sinkStack,
        Object state, IMessage msg, ITransportHeaders headers)
    {
        return null;
    } //GetResponseStream

    /** @property 
     */
    public IServerChannelSink get_NextChannelSink()
    {
        return nextSink2;
    }//get_NextChannelSink
} //LoggingServerChannelSink

.NET Framework-Sicherheit

Vererbungshierarchie

System.Object
  System.Runtime.Remoting.Channels.BaseChannelObjectWithProperties
     System.Runtime.Remoting.Channels.BaseChannelSinkWithProperties
     System.Runtime.Remoting.Channels.BaseChannelWithProperties

Threadsicherheit

Alle öffentlichen statischen (Shared in Visual Basic) Member dieses Typs sind threadsicher. Bei Instanzmembern ist die Threadsicherheit nicht gewährleistet.

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

BaseChannelObjectWithProperties-Member
System.Runtime.Remoting.Channels-Namespace