RequestContext RequestContext RequestContext RequestContext Class

定義

提供與傳入要求相互關聯的回覆。Provides a reply that is correlated to an incoming request.

public ref class RequestContext abstract : IDisposable
public abstract class RequestContext : IDisposable
type RequestContext = class
    interface IDisposable
Public MustInherit Class RequestContext
Implements IDisposable
繼承
RequestContextRequestContextRequestContextRequestContext
實作

備註

您可以從 IReplyChannel 取得要求內容。You get a request context from an IReplyChannel. 每個 RequestContext 會封裝回覆要求所需的資訊,因此當等候每個要求訊息接收回覆時就不需要封鎖通道。Each RequestContext encapsulates the information required to reply to the request, so that you do not have to block on the channel when waiting for each request message to receive a reply.

在要求/回覆模型中,RequestContext 物件是傳入要求與傳出回覆之間的連結。當伺服器接收要求時,會提供代表通道要求的 RequestContext 執行個體。In the request/reply model, the RequestContext object is the link between the request that comes in and the reply that goes out. When the server receives a request, it provides a RequestContext instance that represents the request to the channel. 除了其他有用的屬性以外,要求內容也會包含原始要求訊息。The request context contains the original request message among other useful properties. 然後這個要求內容就會隱藏在 OperationContext 中以便讓服務擷取。This request context is then stashed inside the OperationContext for retrieval by your service. 您通常會使用 Current 屬性存取目前作業的要求。You typically use the Current property to access the request of the current operation.

RequestContext 的值可以是 nullThe value of the RequestContext can be null. 因為要求內容的角色是將要求連結至回覆,所以當沒有回覆時就不需要要求內容,因此在此例中內容會設定為 nullBecause the role of the request context is to link requests to replies, it does not make sense to have a request context when you do not have a reply, and so in this case the context is set to null. 針對要求/回覆模型上方的單向作業,伺服器會接收要求但是不會將回應傳回至用戶端。For a one-way operation on top of the request/reply model, the server receives requests but does not send back a response to the client. 所以如果 RequestContext 意外成為 null,請先檢查作業合約是否為 IsOneWay。So if the RequestContext is null unexpectedly, check first whether the operation contract is IsOneWay.

給衍生自此類別之 Managed C++ 使用者的特別說明:Special note for Managed C++ users deriving from this class:

  • 請將您的清除程式碼置於 (On)(Begin)Close (and/or OnAbort),而不是解構函式。Put your cleanup code in (On)(Begin)Close (and/or OnAbort), not in a destructor.

  • 避免使用解構函式,因為它們會導致編譯器自動產生 IDisposableAvoid destructors: they cause the compiler to auto-generate IDisposable.

  • 避免使用非參考成員,因為它們會導致編譯器自動產生 IDisposableAvoid non-reference members: they can cause the compiler to auto-generate IDisposable.

  • 避免使用完成項,但如果您要加入完成項,則應隱藏建置警告並從 (On)(Begin)Close (和/或 OnAbort) 呼叫 SuppressFinalize(Object)IDisposable和完成項本身,以模擬原本可能自動產生的 行為。Avoid finalizers; but if you include one, you should suppress the build warning and call SuppressFinalize(Object) and the finalizer itself from (On)(Begin)Close (and/or OnAbort) to emulate what would have been the auto-generated IDisposable behavior.

建構函式

RequestContext() RequestContext() RequestContext() RequestContext()

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

屬性

RequestMessage RequestMessage RequestMessage RequestMessage

在衍生類別 (Derived Class) 中覆寫時,取得包含要求的訊息。When overridden in a derived class, gets the message that contains the request.

方法

Abort() Abort() Abort() Abort()

在衍生類別中覆寫時,中止處理與內容關聯的要求。When overridden in a derived class, aborts processing the request associated with the context.

BeginReply(Message, AsyncCallback, Object) BeginReply(Message, AsyncCallback, Object) BeginReply(Message, AsyncCallback, Object) BeginReply(Message, AsyncCallback, Object)

在衍生類別中覆寫時,開始非同步作業以回覆與目前內容關聯的要求。When overridden in a derived class, begins an asynchronous operation to reply to the request associated with the current context.

BeginReply(Message, TimeSpan, AsyncCallback, Object) BeginReply(Message, TimeSpan, AsyncCallback, Object) BeginReply(Message, TimeSpan, AsyncCallback, Object) BeginReply(Message, TimeSpan, AsyncCallback, Object)

在衍生類別中覆寫時,在指定時間間隔內開始非同步作業以回覆與目前內容關聯的要求。When overridden in a derived class, begins an asynchronous operation to reply to the request associated with the current context within a specified interval of time.

Close() Close() Close() Close()

在衍生類別中覆寫時,關閉回覆與目前內容關聯之要求內容的作業。When overridden in a derived class, closes the operation that is replying to the request context associated with the current context.

Close(TimeSpan) Close(TimeSpan) Close(TimeSpan) Close(TimeSpan)

在衍生類別中覆寫時,在指定時間間隔內關閉回覆與目前內容關聯之要求內容的作業。When overridden in a derived class, closes the operation that is replying to the request context associated with the current context within a specified interval of time.

Dispose(Boolean) Dispose(Boolean) Dispose(Boolean) Dispose(Boolean)

釋放與內容相關聯的資源。Releases resources associated with the context.

EndReply(IAsyncResult) EndReply(IAsyncResult) EndReply(IAsyncResult) EndReply(IAsyncResult)

在衍生類別中覆寫時,完成非同步作業以回覆要求訊息。When overridden in a derived class, completes an asynchronous operation to reply to a request message.

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

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

(Inherited from 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)
Reply(Message) Reply(Message) Reply(Message) Reply(Message)

在衍生類別中覆寫時,回覆要求訊息。When overridden in a derived class, replies to a request message.

Reply(Message, TimeSpan) Reply(Message, TimeSpan) Reply(Message, TimeSpan) Reply(Message, TimeSpan)

在衍生類別中覆寫時,在指定時間間隔內回覆要求訊息。When overridden in a derived class, replies to a request message within a specified interval of time.

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

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

(Inherited from Object)

明確介面實作

IDisposable.Dispose() IDisposable.Dispose() IDisposable.Dispose() IDisposable.Dispose()

同時釋放與內容關聯的 Managed 和 Unmanaged 資源。Releases both managed and unmanaged resources associated with the context.

適用於