-
-
Notifications
You must be signed in to change notification settings - Fork 14
Open
Labels
Question ❔Issue is a questionIssue is a question
Milestone
Description
Description
We have a scenario where we can registry in config file 2 Singleton of the same type but different dll version. In the background we have 2dll classes (Only different version) which all implement the desired interface. We would like to use Unity to resolve 2 instances for this interface.
To Reproduce
- Create config file
<unity>
<aliases>
<add alias="DtmParameter1" type="FullFrameworkLibLogic.DtmParameter, FullFrameworkLibLogic, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
<add alias="DtmParameter2" type="FullFrameworkLibLogic.DtmParameter, FullFrameworkLibLogic, Version=5.5.5.5, Culture=neutral, PublicKeyToken=null" />
<add alias="my" type="FullFrameworkLibLogic.DtmParameter, FullFrameworkLibLogic" />
</aliases>
<container>
<register name="1" type="IDtmParameter" mapTo="DtmParameter1">
<lifetime type="singleton" />
</register>
<register name="2" type="IDtmParameter" mapTo="DtmParameter2">
<lifetime type="singleton" />
</register>
</container>
</unity>
</configuration>
- Test like this
[TestMethod]
public void SomeDescriptiveName()
{
IDtmParameter dtmParameter1 = this.container.Resolve<IDtmParameter>("1");
var msg1 = dtmParameter1.GetVersion();
Console.WriteLine(msg1);
IDtmParameter dtmParameter2 = this.container.Resolve<IDtmParameter>("2");
var msg2 = dtmParameter2.GetVersion();
Console.WriteLine(msg2);
}
Metadata
Metadata
Assignees
Labels
Question ❔Issue is a questionIssue is a question
