IContextManager 介面

定義

定義可讓您取得和設定通道內容的介面。

public interface class IContextManager
public interface IContextManager
type IContextManager = interface
Public Interface IContextManager

備註

針對使用 WSHttpContextBinding 且設定 NotAllowed 值的通道,在使用 IContextManager 的用戶端上會無法擷取內容,因為每次呼叫 GetProperty 時,就會建立新的通道來建立工作階段,強制在通道上執行 NotAllowed 語意。 這表示,在這個例子中,即使內容已適當傳播回用戶端,也無法使用 IContextManager 加以擷取。 您仍然可以使用 ContextMessageProperty 來擷取它,如下列程式碼所示。

using (new OperationContextScope((IContextChannel)channel))  
{  
    channel.MyChannel("Test");  
    ContextMessageProperty context;  
    if (ContextMessageProperty.TryGet(OperationContext.Current.IncomingMessageProperties, out context))  
    {  
        Console.WriteLine(context.Count);  
    }  
}  

屬性

Enabled

取得或設定值,這個值表示內容管理是否已啟用。

方法

GetContext()

取得內容。

SetContext(IDictionary<String,String>)

設定內容。

適用於