Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

IContractBehavior::ApplyDispatchBehavior Method (ContractDescription^, ServiceEndpoint^, DispatchRuntime^)

 

Implements a modification or extension of the client across a contract.

Namespace:   System.ServiceModel.Description
Assembly:  System.ServiceModel (in System.ServiceModel.dll)

void ApplyDispatchBehavior(
	ContractDescription^ contractDescription,
	ServiceEndpoint^ endpoint,
	DispatchRuntime^ dispatchRuntime
)

Parameters

contractDescription
Type: System.ServiceModel.Description::ContractDescription^

The contract description to be modified.

endpoint
Type: System.ServiceModel.Description::ServiceEndpoint^

The endpoint that exposes the contract.

dispatchRuntime
Type: System.ServiceModel.Dispatcher::DispatchRuntime^

The dispatch runtime that controls service execution.

Implement the ApplyDispatchBehavior to view, modify, or add custom extensions to the service runtime across all messages in a specific contract or for one specific operation in that contract. For details about what customizations you can perform in a service application, see DispatchRuntime and DispatchOperation.

The ApplyDispatchBehavior method can throw a NotImplementedException exception if the behavior is only intended for use in a client application.

This method is called once for each endpoint that uses the specified service contract.

Note that there can be two operations with the same name in the description (one in each direction), so if you must iterate through operations where the contract is a duplex contract, you must correlate the message direction between the endpoint DispatchRuntime and that returned by the CallbackClientRuntime property.

In addition, because other behaviors may have already added or removed some operations from the runtime, there is no guarantee that there are the same number of operations in description as there are DispatchOperation objects in the Operations property.

The following code example assumes a custom IInstanceProvider implementation called ObjectProviderBehavior that provides a "singleton" behavior; it always returns the same service instance and does not recycle it.

To insert the instance provider customization, the example shows how to implement a custom attribute (SingletonBehaviorAttribute) that implements IContractBehavior to insert the custom service instance provider. It also implements IContractBehaviorAttribute, which binds its use to the ISampleService contract.

No code example is currently available or this language may not be supported.

Universal Windows Platform
Available since 8
.NET Framework
Available since 3.0
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 4.0
Return to top
Show:
© 2017 Microsoft