共用方式為


BaseChannelSinkWithProperties 類別

定義

提供基底實作給想要向其屬性公開字典介面的通道接收。

public ref class BaseChannelSinkWithProperties abstract : System::Runtime::Remoting::Channels::BaseChannelObjectWithProperties
public abstract class BaseChannelSinkWithProperties : System.Runtime.Remoting.Channels.BaseChannelObjectWithProperties
[System.Runtime.InteropServices.ComVisible(true)]
public abstract class BaseChannelSinkWithProperties : 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
[<System.Runtime.InteropServices.ComVisible(true)>]
type BaseChannelSinkWithProperties = class
    inherit BaseChannelObjectWithProperties
[<System.Runtime.InteropServices.ComVisible(true)>]
[<System.Security.SecurityCritical>]
type BaseChannelSinkWithProperties = class
    inherit BaseChannelObjectWithProperties
Public MustInherit Class BaseChannelSinkWithProperties
Inherits BaseChannelObjectWithProperties
繼承
BaseChannelSinkWithProperties
屬性

範例

[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;
      }

   }

};
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

備註

通道接收提供外掛程式點,允許存取流經通道的基礎訊息,以及傳輸機制用來將訊息傳送至遠端物件的數據流。 通道接收會在通道接收提供者鏈結中連結在一起,而所有通道訊息都會在訊息串行化和傳輸之前流經此接收鏈結。

這個類別會在類別層級建立連結需求和繼承需求。 SecurityException當立即呼叫端或衍生類別沒有基礎結構權限時,就會擲回 。 如需安全性需求的詳細資訊,請參閱 連結需求繼承需求

給實施者的注意事項

當您繼承自 BaseChannelSinkWithProperties時,必須實作 Keys 屬性和 Item[Object] 屬性。

建構函式

BaseChannelSinkWithProperties()

初始化 BaseChannelSinkWithProperties 類別的新執行個體。

屬性

Count

取得與通道物件相關聯的屬性數目。

(繼承來源 BaseChannelObjectWithProperties)
IsFixedSize

取得值,指出可輸入到通道物件的屬性數目是否為固定的。

(繼承來源 BaseChannelObjectWithProperties)
IsReadOnly

取得值,指出通道物件中的屬性集合是否為唯讀。

(繼承來源 BaseChannelObjectWithProperties)
IsSynchronized

取得值,指出通道物件屬性的字典是否已經同步 (Synchronize)。

(繼承來源 BaseChannelObjectWithProperties)
Item[Object]

在衍生類別中覆寫時,取得或設定與指定之索引鍵相關聯的屬性。

(繼承來源 BaseChannelObjectWithProperties)
Keys

在衍生類別中覆寫時,取得與通道物件屬性相關聯之索引鍵的 ICollection

(繼承來源 BaseChannelObjectWithProperties)
Properties

取得與通道物件相關聯之通道屬性的 IDictionary

(繼承來源 BaseChannelObjectWithProperties)
SyncRoot

取得可用來對 BaseChannelObjectWithProperties 同步存取的物件。

(繼承來源 BaseChannelObjectWithProperties)
Values

取得與通道物件相關聯之屬性值的 ICollection

(繼承來源 BaseChannelObjectWithProperties)

方法

Add(Object, Object)

擲回 NotSupportedException

(繼承來源 BaseChannelObjectWithProperties)
Clear()

擲回 NotSupportedException

(繼承來源 BaseChannelObjectWithProperties)
Contains(Object)

傳回值,指出通道物件是否包含與指定之索引鍵相關聯的屬性。

(繼承來源 BaseChannelObjectWithProperties)
CopyTo(Array, Int32)

擲回 NotSupportedException

(繼承來源 BaseChannelObjectWithProperties)
Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetEnumerator()

傳回 IDictionaryEnumerator,其列舉與通道物件相關聯的所有屬性。

(繼承來源 BaseChannelObjectWithProperties)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
Remove(Object)

擲回 NotSupportedException

(繼承來源 BaseChannelObjectWithProperties)
ToString()

傳回代表目前物件的字串。

(繼承來源 Object)

明確介面實作

IEnumerable.GetEnumerator()

傳回 IEnumerator,其列舉與通道物件相關聯的所有屬性。

(繼承來源 BaseChannelObjectWithProperties)

擴充方法

Cast<TResult>(IEnumerable)

IEnumerable 的項目轉換成指定的型別。

OfType<TResult>(IEnumerable)

根據指定的型別來篩選 IEnumerable 的項目。

AsParallel(IEnumerable)

啟用查詢的平行化作業。

AsQueryable(IEnumerable)

IEnumerable 轉換成 IQueryable

適用於