Reputation: 8337
I have a service contract as follow
[ServiceContract]
public interface IService
{
[MyCustomBehavior]
[OperationContract]
void MyOperation();
}
The question is whether a call to
new ChannelFactory<IService>(myBinding, myUri)
Will implicitly add MyCustomBehavior before the call, just by virtue of me passing the IService to the ChannelFactory or will I need to dig deeper and explicitly set MyCustomBehavior to the MyOperation operation?
Upvotes: 1
Views: 2347
Reputation: 22076
Operation Behaviors
Operation behaviors, which implement the IOperationBehavior interface, are used to extend both the client and service runtime for each operation.
There are two mechanisms for adding operation behaviors to an operation. The first mechanism is to create a custom attribute to be used on the method that models the operation. When an operation is added to either a ServiceHost or a ChannelFactory, WCF adds any IOperationBehavior attributes to the behaviors collection on the OperationDescription created for that operation.
The second mechanism is by directly adding the behavior to the behaviors collection on a constructed OperationDescription.
I will suggest you to read this first.
Configuring and Extending the Runtime with Behaviors
Upvotes: 1