How is it possible to register a component in Castle Windsor 3.0 with PerWcfOperation lifestyle? I could only find examples of registering components in code.
Here is my config:
<castle>
<facilities>
<facility id="wcf"
type="Castle.Facilities.WcfIntegration.WcfFacility, Castle.Facilities.WcfIntegration" />
</facilities>
<components>
<component id="Settings"
service="SomeNamespace.IApplicationSettings, SomeAssembly"
type="SomeOtherNamespace.ApplicationSettings, SomeOtherAssembly"
lifestyle="PerWcfOperation" />
</components>
</castle>
When I try to do it as in the config above, I get ConvertException ‘Could not convert from ‘PerWcfOperation’ to Castle.Core.LifestyleType.’
It’s not supported because XML configuration is considered legacy.
Use configuration in code instead.
XML and code are generally mostly equivalent (where that’s possible) although this case is an exception – there’s currently no way out of the box to specify scoped lifestyle (and that is what per-wcf-operation lifestyle is) in XML.
Obviously that doesn’t mean there’s no way to get this working. With a simple
IContributeComponentModelConstructionyou can implement support for that in a few LOC.