BaseChannelObjectWithProperties BaseChannelObjectWithProperties BaseChannelObjectWithProperties BaseChannelObjectWithProperties Class

定義

提供要將字典介面公開 (Expose) 至其屬性之通道物件的基底實作。Provides a base implementation of a channel object that exposes a dictionary interface to its properties.

public ref class BaseChannelObjectWithProperties abstract : System::Collections::IDictionary
[System.Runtime.InteropServices.ComVisible(true)]
[System.Security.SecurityCritical]
public abstract class BaseChannelObjectWithProperties : System.Collections.IDictionary
type BaseChannelObjectWithProperties = class
    interface IDictionary
    interface ICollection
    interface IEnumerable
Public MustInherit Class BaseChannelObjectWithProperties
Implements IDictionary
繼承
BaseChannelObjectWithPropertiesBaseChannelObjectWithPropertiesBaseChannelObjectWithPropertiesBaseChannelObjectWithProperties
衍生
屬性
實作

範例

   [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;
         }
      }
   };
}
   [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")> _
 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

備註

BaseChannelObjectWithProperties 是基底類別BaseChannelWithPropertiesBaseChannelSinkWithPropertiesBaseChannelObjectWithProperties is the base class for BaseChannelWithProperties and BaseChannelSinkWithProperties.

BaseChannelWithPropertiesBaseChannelSinkWithProperties便能以通道和通道接收提供的基底類別,名為 「 屬性。BaseChannelWithProperties and BaseChannelSinkWithProperties can be used as the base classes for channels and channel sinks that provide named properties.

BaseChannelObjectWithProperties 處理要求的通道物件其屬性的複雜工作。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. ASecurityException立即呼叫端或衍生的類別沒有基礎結構權限時,會擲回。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.

給繼承者的注意事項

當您繼承自BaseChannelObjectWithProperties,您必須覆寫Keys屬性和Item[Object]屬性。When you inherit from BaseChannelObjectWithProperties, you must override the Keys property and the Item[Object] property.

建構函式

BaseChannelObjectWithProperties() BaseChannelObjectWithProperties() BaseChannelObjectWithProperties() BaseChannelObjectWithProperties()

初始化 BaseChannelObjectWithProperties 類別的新執行個體。Initializes a new instance of the BaseChannelObjectWithProperties class.

屬性

Count Count Count Count

取得與通道物件相關聯的屬性數目。Gets the number of properties associated with the channel object.

IsFixedSize IsFixedSize IsFixedSize IsFixedSize

取得值,指出可輸入到通道物件的屬性數目是否為固定的。Gets a value that indicates whether the number of properties that can be entered into the channel object is fixed.

IsReadOnly IsReadOnly IsReadOnly IsReadOnly

取得值,指出通道物件中的屬性集合是否為唯讀。Gets a value that indicates whether the collection of properties in the channel object is read-only.

IsSynchronized IsSynchronized IsSynchronized IsSynchronized

取得值,指出通道物件屬性的字典是否已經同步 (Synchronize)。Gets a value that indicates whether the dictionary of channel object properties is synchronized.

Item[Object] Item[Object] Item[Object] Item[Object]

在衍生類別中覆寫時,取得或設定與指定之索引鍵相關聯的屬性。When overridden in a derived class, gets or sets the property that is associated with the specified key.

Keys Keys Keys Keys

在衍生類別中覆寫時,取得與通道物件屬性相關聯之索引鍵的 ICollectionWhen overridden in a derived class, gets a ICollection of keys that the channel object properties are associated with.

Properties Properties Properties Properties

取得與通道物件相關聯之通道屬性的 IDictionaryGets a IDictionary of the channel properties associated with the channel object.

SyncRoot SyncRoot SyncRoot SyncRoot

取得可用來對 BaseChannelObjectWithProperties 同步存取的物件。Gets an object that is used to synchronize access to the BaseChannelObjectWithProperties.

Values Values Values Values

取得與通道物件相關聯之屬性值的 ICollectionGets a ICollection of the values of the properties associated with the channel object.

方法

Add(Object, Object) Add(Object, Object) Add(Object, Object) Add(Object, Object)

擲回 NotSupportedExceptionThrows a NotSupportedException.

Clear() Clear() Clear() Clear()

擲回 NotSupportedExceptionThrows a NotSupportedException.

Contains(Object) Contains(Object) Contains(Object) Contains(Object)

傳回值,指出通道物件是否包含與指定之索引鍵相關聯的屬性。Returns a value that indicates whether the channel object contains a property that is associated with the specified key.

CopyTo(Array, Int32) CopyTo(Array, Int32) CopyTo(Array, Int32) CopyTo(Array, Int32)

擲回 NotSupportedExceptionThrows a NotSupportedException.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetEnumerator() GetEnumerator() GetEnumerator() GetEnumerator()

傳回 IDictionaryEnumerator,其列舉與通道物件相關聯的所有屬性。Returns a IDictionaryEnumerator that enumerates over all the properties associated with the channel object.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

(Inherited from Object)
Remove(Object) Remove(Object) Remove(Object) Remove(Object)

擲回 NotSupportedExceptionThrows a NotSupportedException.

ToString() ToString() ToString() ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(Inherited from Object)

明確介面實作

IEnumerable.GetEnumerator() IEnumerable.GetEnumerator() IEnumerable.GetEnumerator() IEnumerable.GetEnumerator()

傳回 IEnumerator,其列舉與通道物件相關聯的所有屬性。Returns a IEnumerator that enumerates over all the properties that are associated with the channel object.

Extension Methods

Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable)

IEnumerable 的項目轉換成指定的型別。Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable)

根據指定的型別來篩選 IEnumerable 的項目。Filters the elements of an IEnumerable based on a specified type.

AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable)

啟用查詢的平行化作業。Enables parallelization of a query.

AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable)

將轉換IEnumerableIQueryableConverts an IEnumerable to an IQueryable.

安全性

SecurityPermission
針對使用基礎結構程式碼執行作業。For operating with infrastructure code. 要求值: InheritanceDemand;權限的值: InfrastructureDemand value: InheritanceDemand; Permission value: Infrastructure

適用於