castle windsor: how to use a Type as constructor property in xml config?
-
03-07-2019 - |
Question
I have the following:
TypeUser:ITypeUser
{
public TypeUser(Type usedType){..}
}
How do i configure the Type parameter in windsor config xml?
Solution
For custom types you need provide a type converter to handle the conversion, however "Type" is supported out of the box (if you take a look at the list here on the castleproject site) and should "just work" i.e. like so:
<component id="myServer" service="SomeNameSpace.ITypeUser, SomeAssembly" type="SomeNameSpace.TypeUser, SomeLib">
<parameters>
<usedType>SomeNameSpace.MyOtherType, SomeAssembly</usedType>
</parameters>
</component>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow