views:

403

answers:

3

I've got a project coming up that will involve connecting to one to many backend systems through the same interface; let's call it IBacksideProvider.

I'd like to use Unity to inject these providers at runtime. The problem is that since we're talking about 1...n backend systems, I'd need to register 1...n implementations of IBacksideProvider. Unity doesn't support this out of the box.

This blog post suggests that it can be done, however. I'm wondering if anybody has done this or has an idea how to go about working Unity so as to be able to do this. TIA.

+2  A: 

Any reason why this wouldn't work? http://msdn.microsoft.com/en-us/library/cc440943.aspx

siz
I'll have to check back on that...
Will
A: 

LinFu.IOC supports IEnumerable<T> and IList<T> injection for constructors, properties, methods, and even fields, all right out of the box. AFAIK, it's one of the very few containers on that blog that actually supports list injection, among other things.

plaureano
+1  A: 

Unity supports array injection as of version 1.2, which was released back in November 2008, or so. This is the best you can do at the moment, without resorting to injection of unity container into your objects.

Ireney Berezniak