IServiceBehavior.AddBindingParameters(ServiceDescription, ServiceHostBase, Collection<ServiceEndpoint>, BindingParameterCollection) 方法
定义
用于向绑定元素传递自定义数据,以支持协定实现。Provides the ability to pass custom data to binding elements to support the contract implementation.
public:
void AddBindingParameters(System::ServiceModel::Description::ServiceDescription ^ serviceDescription, System::ServiceModel::ServiceHostBase ^ serviceHostBase, System::Collections::ObjectModel::Collection<System::ServiceModel::Description::ServiceEndpoint ^> ^ endpoints, System::ServiceModel::Channels::BindingParameterCollection ^ bindingParameters);
public void AddBindingParameters (System.ServiceModel.Description.ServiceDescription serviceDescription, System.ServiceModel.ServiceHostBase serviceHostBase, System.Collections.ObjectModel.Collection<System.ServiceModel.Description.ServiceEndpoint> endpoints, System.ServiceModel.Channels.BindingParameterCollection bindingParameters);
abstract member AddBindingParameters : System.ServiceModel.Description.ServiceDescription * System.ServiceModel.ServiceHostBase * System.Collections.ObjectModel.Collection<System.ServiceModel.Description.ServiceEndpoint> * System.ServiceModel.Channels.BindingParameterCollection -> unit
Public Sub AddBindingParameters (serviceDescription As ServiceDescription, serviceHostBase As ServiceHostBase, endpoints As Collection(Of ServiceEndpoint), bindingParameters As BindingParameterCollection)
参数
- serviceDescription
- ServiceDescription
服务的服务说明。The service description of the service.
- serviceHostBase
- ServiceHostBase
服务的宿主。The host of the service.
- endpoints
- Collection<ServiceEndpoint>
服务终结点。The service endpoints.
- bindingParameters
- BindingParameterCollection
绑定元素可访问的自定义对象。Custom objects to which binding elements have access.
注解
使用 AddBindingParameters 方法可以将自定义对象添加到 parameters 集合,绑定元素可利用该集合获取额外信息,从而向协定提供支持。Use the AddBindingParameters method to add custom data objects to the parameters collection that binding elements can use to acquire extra information to enable them to support the contract.
对每个侦听 URI 都调用一次该方法。This method is called once for each listen URI. 例如,如果一个服务有四个终结点,其中两个终结点的侦听 URI 相同,则此方法将会被调用三次。For example, if a service has four endpoints, and two of them have the same listen URI, then this method gets called three times. 原因是,bindingParameters 要定位所有通道堆栈,每个侦听 URI 都有一个通道堆栈。The reason is that the bindingParameters target each channel stack and there is one channel stack for each listen URI. 因为每个调用都要在侦听 URI 接收这些终结点,所以有两个调用将会各自获得一个单独的 System.ServiceModel.Description.ServiceEndpoint,另一个调用将会获得两个 System.ServiceModel.Description.ServiceEndpoint 对象的集合。Because each call receives those endpoints at that listen URI, two calls each get a single System.ServiceModel.Description.ServiceEndpoint, and one call gets a collection of two System.ServiceModel.Description.ServiceEndpoint objects.
备注
所有 IServiceBehavior 方法会将 System.ServiceModel.Description.ServiceDescription 和 System.ServiceModel.ServiceHostBase 对象作为参数传递。All of the IServiceBehavior methods pass System.ServiceModel.Description.ServiceDescription and System.ServiceModel.ServiceHostBase objects as a parameters. ServiceDescription 参数仅用于自定义检查和插入;如果您修改了这些对象,则执行行为将不确定。The ServiceDescription parameter is for examination and insertion of customizations only; if you otherwise modify these objects the execution behavior is undefined.