Monday, 26 August 2013

DI with Unity when multiple instances of the same type is needed

DI with Unity when multiple instances of the same type is needed

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
{
Example(IQueue receiveQueue, IQueue sendQueue) {}
}
....and IQueue is implemented in my MessageQueue class....
class MessageQueue : IQueue
{
MessageQueue(string path) {}
}
How can I inject two different instances of MessageQueue into my Example
class? Each of the MessageQueue instances to be created with different
path.

No comments:

Post a Comment