CustomBinding 构造函数
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
初始化 CustomBinding 类的新实例。
重载
CustomBinding() |
初始化 CustomBinding 类的新实例。 |
CustomBinding(IEnumerable<BindingElement>) |
使用完整通道堆栈中的绑定元素初始化 CustomBinding 类的新实例。 |
CustomBinding(Binding) |
从指定绑定的值初始化 CustomBinding 类的新实例。 |
CustomBinding(BindingElement[]) |
使用一个绑定元素数组初始化 CustomBinding 类的新实例。 |
CustomBinding(String) |
初始化 CustomBinding 类的新实例。 |
CustomBinding(String, String, BindingElement[]) |
从一个具有指定名称和命名空间的绑定元素数组初始化 CustomBinding 类的新实例。 |
CustomBinding()
- Source:
- CustomBinding.cs
- Source:
- CustomBinding.cs
- Source:
- CustomBinding.cs
初始化 CustomBinding 类的新实例。
public:
CustomBinding();
public CustomBinding ();
Public Sub New ()
示例
以下示例演示如何使用无参数构造函数:
适用于
CustomBinding(IEnumerable<BindingElement>)
- Source:
- CustomBinding.cs
- Source:
- CustomBinding.cs
- Source:
- 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)
- Source:
- CustomBinding.cs
- Source:
- CustomBinding.cs
- Source:
- 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
为 null
。
适用于
CustomBinding(BindingElement[])
- Source:
- CustomBinding.cs
- Source:
- CustomBinding.cs
- Source:
- 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[])
- Source:
- CustomBinding.cs
- Source:
- CustomBinding.cs
- Source:
- 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)