此區段允許使用來自機器或應用程式設定檔的使用者自訂綁定。 你可以透過關鍵字 add 將該元素的屬性設定 type 為使用者定義的綁定 name ,以及設定為使用者定義綁定名稱的設定,將使用者自訂綁定加入此集合。
綁定擴充功能允許使用者建立自訂綁定,作為端點設定的一部分。 在程式設計上,綁定擴充是一種實作抽象類別 Binding的型別。
以下範例使用元素addname及屬性,為設定檔的該區段添加綁定副名bindingExtensions:
<system.serviceModel>
<extensions>
<bindingExtensions>
<add name="MyBinding"
type="Microsoft.ServiceModel.Samples.MyBinding, MyBinding,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
</bindingExtensions>
</extensions>
</system.serviceModel>
要為元素增加設定能力,使用者需要撰寫並註冊一個 bindingSection 元素。 欲了解更多相關資訊,請參閱 System.Configuration 相關文件。
在定義元素及其配置類型後,擴展可作為端點的一部分使用,如下範例所示:
<services>
<service name="MyService">
<endpoint address="myAddress"
binding="MyBinding" />
</service>
</services>