Udostępnij za pośrednictwem


IContractBehavior Interface

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Implements methods that can be used to extend run-time behavior for a contract in a Silverlight application.

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

Syntax

'Declaration
Public Interface IContractBehavior
public interface IContractBehavior

The IContractBehavior type exposes the following members.

Methods

  Name Description
Public method AddBindingParameters Configures any binding elements to support the contract behavior.
Public method ApplyClientBehavior Implements a modification or extension of the client across a contract.
Public method ApplyDispatchBehavior This method is not used in the current implementation of Silverlight.
Public method Validate Implement to confirm that the contract and endpoint can support the contract behavior.

Top

Remarks

Implement the IContractBehavior interface to modify, examine, or extend some aspect of contract-wide execution at the application level.

  • Use the AddBindingParameters method to provide binding elements with custom data to support the behavior.

  • Use the ApplyClientBehavior method to modify, examine, or insert extensions to a contract in a client application.

  • The ApplyDispatchBehavior method is not used in the current implementation of Silverlight.

  • Use the Validate method to ensure that a contract can support a particular feature.

IContractBehavior objects can make use of any of these methods, but often only one is important; in such cases, the unused methods can return without any value.

NoteNote:

All of the IContractBehavior methods pass System.ServiceModel.Description.ContractDescription and System.ServiceModel.Description.ServiceEndpoint as parameters. These parameters are for examination; if you modify the objects the execution behavior is undefined.

IContractBehavior types can be used on either the service or the client, or both.

To perform the customization task on the client for which it is intended, the IContractBehavior object must be added to the Behaviors property prior to the construction of the client runtime, which occurs when ChannelFactory<TChannel>.CreateChannel is called. There are two ways to do this:

Version Information

Silverlight

Supported in: 5, 4

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.