Unity Auto Registration

Oct 7, 2009 at 10:11 PM
Edited Oct 7, 2009 at 10:15 PM


I used auto registration in various IoC containers before and really enjoyed it, so couldn't let my Unity projects live without it. So I have created Unity Auto Registration, and want to share it.

I have tried to cover everything I usually need and to make fluent syntax of configuring conventions more simple but yet more expressive than in other IoC containers.

Enjoy - http://autoregistration.codeplex.com/

Just as an example of how you can configure your container to auto register types:

var container = new UnityContainer();

                .ExcludeAssemblies(a => a.GetName().FullName.Contains("Test"))
                .Include(If.Implements<ILogger>, Then.Register().UsingPerCallMode())
                .Include(If.ImplementsITypeName, Then.Register().WithTypeName())
                .Include(If.Implements<ICustomerRepository>, Then.Register().WithName("Sample"))
                .Exclude(t => t.Name.Contains("Trace"))
Mar 12, 2013 at 10:42 PM
A quick update.

Autoregistration is added to Unity in v3.0. See this post.