Unity 2.0 and Creation by Assembly

Sep 24, 2010 at 10:23 PM

I would like to use the Unity application block for dependency injection at an assembly level without having to specify every type mapping.  What I am looking for is something where either through configuration or implicitly I can specify that unity should look in Assembly X to resolve any references for interfaces defined Assembly Y.  So when I call container.Resolve<Interface>, it will look in Assembly X for the class that implements this interface.  Structure map allows the system to do this, but I haven't found a way to do so using Unity.  Is this possible?  Thanks.

Sep 24, 2010 at 11:47 PM

There is nothing built in at this time. The reflection code required to do something like this is about 50 lines give or take, so I haven't prioritized building it. I obviously need to put something out there, I'll see what I can do.

This is really, really easy to do on top of the existing container API, assuming you know how to do reflection.


Sep 27, 2010 at 1:03 AM

You might want to take a look at Unity Auto Registration on codeplex


I've used it as a basis for my own "register by policy" xml configuration extensions