I have a class that i want to instantiate thru castle in configuration.
public class MyMappings : IMappings
{
Mapping FirstMapping { get; set; }
Mapping SecondMapping { get; set; }
OtherType ThirdMapping { get; set; }
OtherType FourthMapping { get; set; }
Mapping FifthMa开发者_如何学Pythonpping { get; set; }
OtherType SixMapping { get; set; }
}
In my configuration i have the following:
< component id="mymappings" type="MyMappings, MyAssmebly" >
< parameters>
< firstMapping>${anothercomponentIDForCompomentOftypeMapping}< /firstMapping>
< /parameters>
< /component>
The problem i am facing is that is assigning the same value to all properties of the same type, completly ignoring the name of the parameter. This properties are optional, i just want to initialize the value for one of them.
Thanks,
If you have components with type Mapping or OtherType registered in the container, Windsor will inject them in your optional dependencies. What you did in your xml configuration is a service override, that is, you selected a specific component for a specific parameter, but that doesn't mean that other parameters will not be injected is a fitting component is available.
If you want to avoid injecting some optional dependencies, see this question.
精彩评论