ClientOperation 類別

定義

用於修改或擴充用戶端物件或用戶端通道物件中特定合約作業的執行行為。 此類別無法獲得繼承。

public ref class ClientOperation sealed
public ref class ClientOperation sealed : System::ServiceModel::Dispatcher::ClientOperationCompatBase
public sealed class ClientOperation
public sealed class ClientOperation : System.ServiceModel.Dispatcher.ClientOperationCompatBase
type ClientOperation = class
type ClientOperation = class
    inherit ClientOperationCompatBase
Public NotInheritable Class ClientOperation
Public NotInheritable Class ClientOperation
Inherits ClientOperationCompatBase
繼承
ClientOperation
繼承

範例

下列程式碼範例將示範 System.ServiceModel.Description.IEndpointBehavior 如何將自訂參數偵測器插入至 ClientOperation 屬性中的每個 ClientRuntime.Operations

#region IEndpointBehavior Members
public void AddBindingParameters(
  ServiceEndpoint endpoint, BindingParameterCollection bindingParameters
) { return; }

public void ApplyClientBehavior(ServiceEndpoint endpoint, ClientRuntime clientRuntime)
{
  clientRuntime.MessageInspectors.Add(new Inspector());
  foreach (ClientOperation op in clientRuntime.Operations)
    op.ParameterInspectors.Add(new Inspector());
}

public void ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher)
{
  endpointDispatcher.DispatchRuntime.MessageInspectors.Add(new Inspector());
  foreach (DispatchOperation op in endpointDispatcher.DispatchRuntime.Operations)
    op.ParameterInspectors.Add(new Inspector());
}

public void Validate(ServiceEndpoint endpoint){ return; }
#Region "IEndpointBehavior Members"
    Public Sub AddBindingParameters(ByVal endpoint As ServiceEndpoint, ByVal bindingParameters _
                                    As BindingParameterCollection) Implements IEndpointBehavior.AddBindingParameters
        Return
    End Sub

    Public Sub ApplyClientBehavior(ByVal endpoint As ServiceEndpoint, ByVal clientRuntime As ClientRuntime) _
    Implements IEndpointBehavior.ApplyClientBehavior
        clientRuntime.MessageInspectors.Add(New Inspector())
        For Each op As ClientOperation In clientRuntime.Operations
            op.ParameterInspectors.Add(New Inspector())
        Next op
    End Sub

    Public Sub ApplyDispatchBehavior(ByVal endpoint As ServiceEndpoint, ByVal endpointDispatcher As  _
                                     EndpointDispatcher) Implements IEndpointBehavior.ApplyDispatchBehavior
        endpointDispatcher.DispatchRuntime.MessageInspectors.Add(New Inspector())
        For Each op As DispatchOperation In endpointDispatcher.DispatchRuntime.Operations
            op.ParameterInspectors.Add(New Inspector())
        Next op
    End Sub

Public Sub Validate(ByVal endpoint As ServiceEndpoint) Implements IEndpointBehavior.Validate
    Return
End Sub

備註

用戶端執行階段修改的位置以及範圍僅限一項服務作業之自訂擴充的插入點,就是 ClientOperation 類別。 (若要修改合約中所有訊息的用戶端執行時間行為,請使用 ClientRuntime 類別。)

使用自訂用戶端行為物件,這個物件的型別可以是 ClientOperation (用來尋找要修改的特定作業) 或 IContractBehavior (可藉由建立自訂屬性加以套用),即可安裝 IOperationBehavior 修改。

您可以使用 Operations 屬性找出表示特定服務作業的 ClientOperation 物件。

如需用戶端和用戶端架構的詳細資訊,請參閱 使用 WCF 用戶端WCF 用戶端架構存取服務。 如需自訂用戶端執行時間的詳細資訊,請參閱 擴充用戶端。 如需使用行為的詳細資訊,請參閱 使用行為設定和擴充執行時間

您可以使用下列屬性來插入自訂物件或修改用戶端執行行為:

  • 使用 Formatter 屬性,即可插入作業的自訂 IClientMessageFormatter 實作或修改目前的格式器。

  • 使用 ParameterInspectors 屬性,即可插入自訂 IParameterInspector 實作或修改目前的實作。

  • 使用 SerializeRequest 屬性,即可控制由誰來序列化傳出訊息。

  • 使用 DeserializeReply 屬性,即可控制由誰來還原序列化傳入訊息。

  • 使用 Action 屬性,即可存取要求訊息的 WS-Addressing 動作,而使用 ReplyAction 屬性便可存取回應訊息動作。

  • 使用 BeginMethodEndMethod,即可指定要與非同步作業產生關聯的用戶端方法。

  • 使用 FaultContractInfos 屬性,即可取得可在 SOAP 錯誤中顯示為詳細類型之指定型別的集合。

  • 使用 IsInitiatingIsTerminating 屬性,即可分別控制在呼叫作業時是否要產生或卸除工作階段。

  • 使用 IsOneWay 屬性,即可控制用戶端是否要在完成引動之前等候回應。

  • 使用 Parent 屬性,即可取得 ClientRuntime 包含物件。

  • 使用 Name 屬性,即可取得作業的名稱。

  • 使用 SyncMethod 屬性,即可控制要對應到作業的方法。

建構函式

ClientOperation(ClientRuntime, String, String)

使用指定的 ClientOperation、名稱和動作值,初始化 ClientRuntime 類別的新執行個體。

ClientOperation(ClientRuntime, String, String, String)

使用指定的 ClientOperation、名稱、動作和回覆動作值,初始化 ClientRuntime 類別的新執行個體。

屬性

Action

取得作業的動作。

BeginMethod

取得或設定與非同步作業相關聯的方法。

ClientParameterInspectors

取得用來檢視或修改用戶端呼叫之前或之後參數的參數偵測器物件集合。

DeserializeReply

取得或設定值,這個值會指出是否使用 Formatter 屬性值來還原序列化回覆訊息。

EndMethod

取得或設定方法,這個方法會實作作業的非同步結束方法。

FaultContractInfos

取得 FaultContractInfo 物件的集合,這些物件表示針對這項作業所指定的 SOAP 錯誤。

Formatter

取得或設定格式器,這個格式器會將物件序列化為訊息以及將訊息還原序列化為物件。

IsInitiating

取得或設定值,這個值會指出工作階段是否可以由傳送給這項作業的訊息來啟動。

IsOneWay

取得或設定值,這個值會指出作業是否為單向作業。

IsTerminating

取得或設定值,這個值會指出這項作業是否為工作階段中的最後一個作業。

Name

取得作業的名稱。

ParameterInspectors

取得或設定 IParameterInspector 物件的集合,這些物件可以檢查和修改特定用戶端方法的傳入及傳出物件。

Parent

取得 ClientRuntime 包含物件。

ReplyAction

取得這項作業之回覆訊息的動作。

SerializeRequest

取得或設定值,這個值會指定 Formatter 物件是否序列化傳出訊息。

SyncMethod

取得或設定與這項作業相關聯的方法。

TaskMethod

取得或設定與工作相關聯的方法。

TaskTResult

取得或設定與工作相關聯之方法的結果型別。

方法

Equals(Object)

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

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
ToString()

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

(繼承來源 Object)

適用於