Export (0) Print
Expand All

BaseChannelObjectWithProperties Class

Provides a base implementation of a channel object that exposes a dictionary interface to its properties.

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

[ComVisibleAttribute(true)]
[SecurityPermissionAttribute(SecurityAction.InheritanceDemand, Flags = SecurityPermissionFlag.Infrastructure)]
[SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.Infrastructure)]
public abstract class BaseChannelObjectWithProperties : IDictionary, 
	ICollection, IEnumerable

BaseChannelObjectWithProperties is the base class for BaseChannelWithProperties and BaseChannelSinkWithProperties.

BaseChannelWithProperties and BaseChannelSinkWithProperties can be used as the base classes for channels and channel sinks that provide named properties.

BaseChannelObjectWithProperties handles the complex task of asking a channel object for its properties.

This class makes a link demand and an inheritance demand at the class level. A SecurityException is thrown when either the immediate caller or the derived class does not have infrastructure permission. For details about security demands, see Link Demands and Inheritance Demands.

Notes to Inheritors:

When you inherit from BaseChannelObjectWithProperties, you must override the Keys property and the Item property.

   [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;
         }
      }
   }
private __gc class LoggingServerChannelSink : public BaseChannelObjectWithProperties, public IServerChannelSink
{
private:
   IServerChannelSink* nextSink2;
   bool bEnabled2;
public:
   LoggingServerChannelSink() : nextSink2(0), bEnabled2(true) {}
   LoggingServerChannelSink(IServerChannelSink* localNextSink) : BaseChannelObjectWithProperties()
   {
      nextSink2 = localNextSink;
   }
   ServerProcessing ProcessMessage( 
      IServerChannelSinkStack* sinkStack,
      IMessage* requestMsg,
      ITransportHeaders* requestHeaders,
      Stream* requestStream,
      [Out]IMessage** responseMsg,
      [Out]ITransportHeaders** responseHeaders,
      [Out]Stream** responseStream
      )
   {
      if (bEnabled2)
      {
         Console::WriteLine(S"----------Request Headers-----------");
         Console::WriteLine( S"{0}:{1}", CommonTransportKeys::IPAddress, requestHeaders->Item[CommonTransportKeys::IPAddress]);
         Console::WriteLine( S"{0}:{1}", CommonTransportKeys::ConnectionId, requestHeaders->Item[CommonTransportKeys::ConnectionId]);
         Console::WriteLine( S"{0}:{1}", CommonTransportKeys::RequestUri, requestHeaders->Item[CommonTransportKeys::RequestUri]);

      }
      sinkStack->Push(this, 0);
      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, 0);
            break;
         }
      }
      return processing;
   }

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

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

   __property IServerChannelSink* get_NextChannelSink()
   {
      return nextSink2;
   }

};

public __gc class LoggingServerChannelSinkProvider : public IServerChannelSinkProvider
{
private:
   IServerChannelSinkProvider* next2;
public:
   LoggingServerChannelSinkProvider() : next2(0) {}
   LoggingServerChannelSinkProvider(IDictionary* /*properties*/, ICollection* /*providerData*/)
   {
   }

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

   IServerChannelSink* CreateSink(IChannelReceiver* channel1)
   {
      IServerChannelSink* localNextSink = 0;
      if (next2 != 0)
         localNextSink = next2->CreateSink(channel1);
      return new LoggingServerChannelSink(localNextSink);
   }

   __property IServerChannelSinkProvider* get_Next()
   {
      return next2;
   }

   __property void set_Next( IServerChannelSinkProvider* value )
   {
      next2 = value;
   }

};

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft