tags:

views:

138

answers:

1

I need to hook into the WCF operation process to execute some code right before and right after each operation.

Some context:

  • I already have a custom servicehost, servicehostfactory and servicebehavior
  • all my services are based on a common base class

I've been snooping around and I think using a IParameterInspector would be the best choice, but I'm not entirely sure given that the code I need to execute has nothing to with parameters...

Any clues?

+2  A: 

IParameterInspector is not a bad choice.

Do you need to know which operation/session/endpoint is happening, or are you just installing the same logic for all operations? Do you need to modify the Message object? (These considerations may change your choice of extensibility point.)

Do you need to modify thread-local storage? If so, prefer ICallContextInitializer.

Brian
Yes, I need thread local storage.Can I setup a CallContextInitializer for each operation automatically (without reverting to an attribute on each contract)?
Inferis
Yeah, you should be able to write a service/endpoint/contract behavior that walks all the operations and pokes each DispatchOperation.CallContextInitializers.
Brian