I need help with this. I\'m using Unity as my container and I want to inject two different instances of the same type into my constructor.
class Example
{
You could register the two instances with names:
myContainer.RegisterInstance("ReceiveQueue", myReceiveMessageQueue);
myContainer.RegisterInstance("SendQueue", mySendMessageQueue);
and then you should be able to resolve by name, but it requires using the Dependency attribute:
class Example
{
Example([Dependency("ReceiveQueue")] IQueue receiveQueue,
[Dependency("SendQueue")] IQueue sendQueue) {
}
}
or inject the unity container and then resolve the instances within the constructor:
class Example
{
Example(IUnityContainter container)
{
_receiveQueue = container.Resolve("ReceiveQueue");
_sendQueue = container.Resolve("SendQueue");
}
}