語言

CustomBinding 建構函式

定義

初始化 CustomBinding 類別的新執行個體。

多載

名稱 Description
CustomBinding()

初始化 CustomBinding 類別的新執行個體。

CustomBinding(IEnumerable<BindingElement>)

初始化該類別的新實例 CustomBinding ,使用完整通道堆疊中的綁定元素。

CustomBinding(Binding)

從指定綁定值初始化該類別的新實例 CustomBinding 。

CustomBinding(BindingElement[])

從一組綁定元素的陣列初始化該 CustomBinding 類別的新實例。

CustomBinding(String)

初始化 CustomBinding 類別的新執行個體。

CustomBinding(String, String, BindingElement[])

從一組結合元素陣列初始化該類別的新實例 CustomBinding ,並指定名稱與命名空間。

CustomBinding()

來源:
CustomBinding.cs
來源:
CustomBinding.cs
來源:
CustomBinding.cs

初始化 CustomBinding 類別的新執行個體。

public:
 CustomBinding();
public CustomBinding();
Public Sub New ()

範例

以下範例展示了如何使用無參數建構子:

適用於

CustomBinding(IEnumerable<BindingElement>)

來源:
CustomBinding.cs
來源:
CustomBinding.cs
來源:
CustomBinding.cs

初始化該類別的新實例 CustomBinding ,使用完整通道堆疊中的綁定元素。

public:
 CustomBinding(System::Collections::Generic::IEnumerable<System::ServiceModel::Channels::BindingElement ^> ^ bindingElementsInTopDownChannelStackOrder);
public CustomBinding(System.Collections.Generic.IEnumerable<System.ServiceModel.Channels.BindingElement> bindingElementsInTopDownChannelStackOrder);
new System.ServiceModel.Channels.CustomBinding : seq<System.ServiceModel.Channels.BindingElement> -> System.ServiceModel.Channels.CustomBinding
Public Sub New (bindingElementsInTopDownChannelStackOrder As IEnumerable(Of BindingElement))

參數

bindingElementsInTopDownChannelStackOrder
IEnumerable<BindingElement>

一個 IEnumerable<T> 型別 BindingElement 包含通道堆疊中按頂層順序綁定元素的 。

例外狀況

bindingElementsInTopDownChannelStackOrder 是 null。

範例

Uri baseAddress = new Uri("http://localhost:8000/servicemodelsamples/service");

// Create a ServiceHost for the CalculatorService type and provide the base address.
ServiceHost serviceHost = new ServiceHost(typeof(CalculatorService), baseAddress);

// Create a custom binding that contains two binding elements.
ReliableSessionBindingElement reliableSession = new ReliableSessionBindingElement();
reliableSession.Ordered = true;

HttpTransportBindingElement httpTransport = new HttpTransportBindingElement();
httpTransport.AuthenticationScheme = System.Net.AuthenticationSchemes.Anonymous;
httpTransport.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard;

SynchronizedCollection<BindingElement> coll = new SynchronizedCollection<BindingElement>();
coll.Add(reliableSession);
coll.Add(httpTransport);

CustomBinding binding = new CustomBinding(coll);
Dim baseAddress As New Uri("http://localhost:8000/servicemodelsamples/service")

' Create a ServiceHost for the CalculatorService type and provide the base address.
Dim serviceHost As New ServiceHost(GetType(CalculatorService), baseAddress)

' Create a custom binding that contains two binding elements.
Dim reliableSession As New ReliableSessionBindingElement()
reliableSession.Ordered = True

Dim httpTransport As New HttpTransportBindingElement()
httpTransport.AuthenticationScheme = System.Net.AuthenticationSchemes.Anonymous
httpTransport.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard

Dim coll As New SynchronizedCollection(Of BindingElement)()
coll.Add(reliableSession)
coll.Add(httpTransport)

Dim binding As New CustomBinding(coll)

適用於

CustomBinding(Binding)

來源:
CustomBinding.cs
來源:
CustomBinding.cs
來源:
CustomBinding.cs

從指定綁定值初始化該類別的新實例 CustomBinding 。

public:
 CustomBinding(System::ServiceModel::Channels::Binding ^ binding);
public CustomBinding(System.ServiceModel.Channels.Binding binding);
new System.ServiceModel.Channels.CustomBinding : System.ServiceModel.Channels.Binding -> System.ServiceModel.Channels.CustomBinding
Public Sub New (binding As Binding)

參數

binding
Binding

那個 Binding 用來初始化自訂綁定。

例外狀況

binding 是 null。

適用於

CustomBinding(BindingElement[])

來源:
CustomBinding.cs
來源:
CustomBinding.cs
來源:
CustomBinding.cs

從一組綁定元素的陣列初始化該 CustomBinding 類別的新實例。

public:
 CustomBinding(... cli::array <System::ServiceModel::Channels::BindingElement ^> ^ bindingElementsInTopDownChannelStackOrder);
public CustomBinding(params System.ServiceModel.Channels.BindingElement[] bindingElementsInTopDownChannelStackOrder);
new System.ServiceModel.Channels.CustomBinding : System.ServiceModel.Channels.BindingElement[] -> System.ServiceModel.Channels.CustomBinding
Public Sub New (ParamArray bindingElementsInTopDownChannelStackOrder As BindingElement())

參數

bindingElementsInTopDownChannelStackOrder
BindingElement[]

用來 Array 初始化自訂綁定的類型 BindingElement 。

例外狀況

bindingElementsInTopDownChannelStackOrder 是 null。

範例

 Uri baseAddress = new Uri("http://localhost:8000/servicemodelsamples/service");

// Create a ServiceHost for the CalculatorService type and provide the base address.
 ServiceHost serviceHost = new ServiceHost(typeof(CalculatorService), baseAddress);

// Create a custom binding that contains two binding elements.
ReliableSessionBindingElement reliableSession = new ReliableSessionBindingElement();
reliableSession.Ordered = true;

HttpTransportBindingElement httpTransport = new HttpTransportBindingElement();
httpTransport.AuthenticationScheme = System.Net.AuthenticationSchemes.Anonymous;
httpTransport.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard;

BindingElement[] elements = new BindingElement[2];
elements[0] = reliableSession;
elements[1] = httpTransport;

CustomBinding binding = new CustomBinding(elements);
 Dim baseAddress As New Uri("http://localhost:8000/servicemodelsamples/service")

' Create a ServiceHost for the CalculatorService type and provide the base address.
 Dim serviceHost As New ServiceHost(GetType(CalculatorService), baseAddress)

' Create a custom binding that contains two binding elements.
Dim reliableSession As New ReliableSessionBindingElement()
reliableSession.Ordered = True

Dim httpTransport As New HttpTransportBindingElement()
httpTransport.AuthenticationScheme = System.Net.AuthenticationSchemes.Anonymous
httpTransport.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard

Dim elements(1) As BindingElement
elements(0) = reliableSession
elements(1) = httpTransport

Dim binding As New CustomBinding(elements)

適用於

CustomBinding(String)

初始化 CustomBinding 類別的新執行個體。

public:
 CustomBinding(System::String ^ configurationName);
public CustomBinding(string configurationName);
new System.ServiceModel.Channels.CustomBinding : string -> System.ServiceModel.Channels.CustomBinding
Public Sub New (configurationName As String)

參數

configurationName
String

屬性的值 configurationName ,用來識別 binding 用於初始化綁定的元素設定。

例外狀況

由 configurationName 所識別的結合元素為 null。

適用於

CustomBinding(String, String, BindingElement[])

來源:
CustomBinding.cs
來源:
CustomBinding.cs
來源:
CustomBinding.cs

從一組結合元素陣列初始化該類別的新實例 CustomBinding ,並指定名稱與命名空間。

public:
 CustomBinding(System::String ^ name, System::String ^ ns, ... cli::array <System::ServiceModel::Channels::BindingElement ^> ^ bindingElementsInTopDownChannelStackOrder);
public CustomBinding(string name, string ns, params System.ServiceModel.Channels.BindingElement[] bindingElementsInTopDownChannelStackOrder);
new System.ServiceModel.Channels.CustomBinding : string * string * System.ServiceModel.Channels.BindingElement[] -> System.ServiceModel.Channels.CustomBinding
Public Sub New (name As String, ns As String, ParamArray bindingElementsInTopDownChannelStackOrder As BindingElement())

參數

name
String

綁定的名字。

ns
String

綁定的命名空間。

bindingElementsInTopDownChannelStackOrder
BindingElement[]

用來 Array 初始化自訂綁定的類型 BindingElement 。

例外狀況

bindingElementsInTopDownChannelStackOrder 是 null。

範例

Uri baseAddress = new Uri("http://localhost:8000/servicemodelsamples/service");

// Create a ServiceHost for the CalculatorService type and provide the base address.
ServiceHost serviceHost = new ServiceHost(typeof(CalculatorService), baseAddress);

// Create a custom binding that contains two binding elements.
ReliableSessionBindingElement reliableSession = new ReliableSessionBindingElement();
reliableSession.Ordered = true;

HttpTransportBindingElement httpTransport = new HttpTransportBindingElement();
httpTransport.AuthenticationScheme = System.Net.AuthenticationSchemes.Anonymous;
httpTransport.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard;

BindingElement[] elements = new BindingElement[2];
elements[0] = reliableSession;
elements[1] = httpTransport;

CustomBinding binding = new CustomBinding("MyCustomBinding", "http://localhost/service", elements);
Dim baseAddress As New Uri("http://localhost:8000/servicemodelsamples/service")

' Create a ServiceHost for the CalculatorService type and provide the base address.
Dim serviceHost As New ServiceHost(GetType(CalculatorService), baseAddress)

' Create a custom binding that contains two binding elements.
Dim reliableSession As New ReliableSessionBindingElement()
reliableSession.Ordered = True

Dim httpTransport As New HttpTransportBindingElement()
httpTransport.AuthenticationScheme = System.Net.AuthenticationSchemes.Anonymous
httpTransport.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard

Dim elements(1) As BindingElement
elements(0) = reliableSession
elements(1) = httpTransport

Dim binding As New CustomBinding("MyCustomBinding", "http://localhost/service", elements)

適用於