views:

31

answers:

1

In WCF some of the settings are written as class attributes. I would like to set them in the configuration file instead.

Examples

[OperationContract(IsOneWay = true)]
[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single,
    ConcurrencyMode = ConcurrencyMode.Multiple)]

Is there any way to do this? Maybe with MicroKernel/Windsor?

+1  A: 

Some settings indeed require attributes (instead of being configurable). Now, while I don't know about all such occurances, at least for some it makes sense. InstanceContextMode and ConcurrencyMode, for example, require a particular implementation style. In other words, the implementiation must be written in a way that actually supports the modes specified (think about statelessness, implementation object lifecycle, etc.).

As a side node: when using DI to create implementation classes for WCF (using a custom InstanceContextInitializer), you must even make sure that you not change the behavior specified through the service behavior. For example, the default lifetime-policy of Windsor is "Single", so whatever you would specify in the ServiceBehavior, you would effectifly use the InstanceContextMode.Single - probably not what you like to have. At least it is not easily discoverable.

Christian.K