CustomBinding Constructors

Definition

Overloads

CustomBinding()

Initializes a new instance of the CustomBinding class.

CustomBinding(IEnumerable<BindingElement>)

Initializes a new instance of the CustomBinding class with the binding elements from a complete channel stack.

CustomBinding(Binding)

Initializes a new instance of the CustomBinding class from the values of a specified binding.

CustomBinding(BindingElement[])

Initializes a new instance of the CustomBinding class from an array of binding elements.

CustomBinding(String)

Initializes a new instance of the CustomBinding class.

CustomBinding(String, String, BindingElement[])

Initializes a new instance of the CustomBinding class from an array of binding elements with a specified name and namespace.

CustomBinding()

Initializes a new instance of the CustomBinding class.

public CustomBinding ();

Examples

The following example shows how to use the default constructor:

CustomBinding(IEnumerable<BindingElement>)

Initializes a new instance of the CustomBinding class with the binding elements from a complete channel stack.

public CustomBinding (System.Collections.Generic.IEnumerable<System.ServiceModel.Channels.BindingElement> bindingElementsInTopDownChannelStackOrder);
Parameters
bindingElementsInTopDownChannelStackOrder
IEnumerable<BindingElement>

An IEnumerable<T> of type BindingElement that contains the binding elements of the channel stack in top-down order.

Exceptions

bindingElementsInTopDownChannelStackOrder is null.

Examples

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)

Initializes a new instance of the CustomBinding class from the values of a specified binding.

public CustomBinding (System.ServiceModel.Channels.Binding binding);
Parameters
binding
Binding

The Binding that is used to initialize the custom binding.

Exceptions

binding is null.

CustomBinding(BindingElement[])

Initializes a new instance of the CustomBinding class from an array of binding elements.

public CustomBinding (params System.ServiceModel.Channels.BindingElement[] bindingElementsInTopDownChannelStackOrder);
Parameters
bindingElementsInTopDownChannelStackOrder
BindingElement[]

The Array of type BindingElement used to initialize the custom binding.

Exceptions

bindingElementsInTopDownChannelStackOrder is null.

Examples

 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)

Initializes a new instance of the CustomBinding class.

public CustomBinding (string name);
Parameters
configurationName
String
Exceptions

The binding element identified by the name is null.

Remarks

The binding element named by

CustomBinding(String, String, BindingElement[])

Initializes a new instance of the CustomBinding class from an array of binding elements with a specified name and namespace.

public CustomBinding (string name, string ns, params System.ServiceModel.Channels.BindingElement[] bindingElementsInTopDownChannelStackOrder);
Parameters
name
String

The name of the binding.

ns
String

The namespace of the binding.

bindingElementsInTopDownChannelStackOrder
BindingElement[]

The Array of type BindingElement used to initialize the custom binding.

Exceptions

bindingElementsInTopDownChannelStackOrder is null.

Examples

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)

Applies to