Reputation: 7243
I wan to configure the unity container using ONLY xml (no fluent API) and I have a complex task. I have an interface which looks like this
public interface ISettingsDistributor {
String TargetProperty;
}
And its implementation SettingsDistributor
public interface ISettingsConsumer { }
public class SettingsConsumer :ISettingsConsumer, OtherType {
public SettingsConsumer(String theParameter) : base(theParameter) {
}
}
This is a consumer of that setting. The following is the configuration section I've built so far. (typeAlias
es and other stuff is omitted)
<containers>
<container name="container">
<types>
<type type="ISettingsDistributor" mapTo="SettingsDistributor">
<lifetime type="singleton" />
</type>
<type type="ISettingsConsumer" mapTo="SettingsConsumer">
<lifetime type="perThread" />
</type>
</types>
</container>
</containers>
How can I say to unity in this xml file that when it tries to resolve the type ISettingsConsumer
it should first resolve the ISettingsDistributor
and inject its TargetProperty
member as a value to the constructor?
Upvotes: 0
Views: 51
Reputation: 6806
Why don't you just inject your ISettingsDistributor?It will be the source of your magic string anyway.So whats the problem with that?
Upvotes: 1