擴充 ServiceHost 與服務模型層Extending ServiceHost and the Service Model Layer

服務模型層負責從基礎通道提取傳入訊息,將它們以應用程式碼轉譯成方法叫用,然後將結果傳回給呼叫者。The service model layer is responsible for pulling incoming messages out of the underlying channels, translating them into method invocations in application code, and sending the results back to the caller. 服務模型延伸會修改或實作涉及用戶端或發送器功能、自訂行為、訊息與參數攔截以及其他擴充性功能的執行或通訊行為與功能。Service model extensions modify or implement execution or communication behavior and features involving client or dispatcher functionality, custom behaviors, message and parameter interception, and other extensibility functionality.

本節內容In This Section

擴充用戶端Extending Clients
說明可攔截與修改用戶端執行階段的介面,以及您可在用戶端應用程式中插入自訂擴充功能的類別。Describes the interfaces that can intercept and modify the client runtime, as well as the classes into which you can insert your custom extensions in client applications. 例如,您可以執行自訂用戶端訊息記錄,以及執行自訂訊息序列化等等。For example, you can perform custom client message logging, perform custom message serialization, and so on.

擴充發送器Extending Dispatchers
說明可攔截與修改服務執行階段的介面,以及您可在服務應用程式中插入自訂擴充功能的類別。Describes the interfaces that can intercept and modify the service runtime, as well as the classes into which you can insert your custom extensions in service applications. 例如,您可執行自訂服務記錄、服務端訊息驗證,以及自訂分派等等。For example, you can perform custom service logging, service-side message validation, custom dispatching, and so on.

可延伸物件Extensible Objects
描述 5 項可擴充物件以及 IExtensibleObject<T> 模式。Describes the five extensible objects and the IExtensibleObject<T> pattern. 可延伸物件模式是用於以新功能延伸現有的執行階段類別,或將新狀態新增至物件。The extensible object pattern is used to either extend existing runtime classes with new functionality or to add new state to an object. 附加至其中一個可擴充物件的擴充功能會在處理程序中的各種不同階段啟用行為,以存取附加至它們可存取之一般可擴充物件的共用狀態與功能。Extensions, attached to one of the extensible objects, enable behaviors at very different stages in processing to access shared state and functionality attached to a common extensible object that they can access.

使用行為來設定與擴充執行階段Configuring and Extending the Runtime with Behaviors
若要在 WCF 執行時間中變更或插入延伸模組的設定,請使用行為。To change settings on or insert extensions in the WCF runtime, you use Behaviors. WCF 包括控制節流、執行個體以及其他許多服務與作業方面的系統實作行為。WCF includes system-implemented behaviors for controlling throttling, instancing, and many other aspects of services and operations. 此章節說明如何建立您自己的自訂行為,以及如何讓它們供程式設計以及使用組態檔時使用。This section describes how to create your own custom behaviors and how to make them available for use both programmatically and using configuration files.

使用 ServiceHostFactory 擴充裝載Extending Hosting Using ServiceHostFactory
說明如何擴充 System.ServiceModel.ServiceHostBase, System.ServiceModel.ServiceHost,以及使用 System.ServiceModel.Activation.ServiceHostFactory 類別自訂主機環境。Describes how to extend System.ServiceModel.ServiceHostBase, System.ServiceModel.ServiceHost, and use the System.ServiceModel.Activation.ServiceHostFactory classes to customize the host environment.

參考資料Reference