IContextManager 介面
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
定義一個介面,讓你能取得並設定頻道上下文。
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);
}
}
屬性
| 名稱 | Description |
|---|---|
| Enabled |
取得或設定一個值,指示上下文管理是否啟用。 |
方法
| 名稱 | Description |
|---|---|
| GetContext() |
了解上下文。 |
| SetContext(IDictionary<String,String>) |
設定背景。 |