0
kicks
Unity Auto Registration (convention over configuration registration)
Unity Auto Registration extends Unity IoC container and provides nice fluent syntax to configure rules for automatic types registration. In a couple of code lines you can scan specified assemblies and register all types implementing certain interface or decorated with certain attribute (or satisfy your own predicate) with certain lifetime managers and names.
For example:
var container = new UnityContainer();
container
.ConfigureAutoRegistration()
.LoadAssemblyFrom("Plugin.dll")
.IncludeAllLoadedAssemblies()
.ExcludeSystemAssemblies()
.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"))
.Include(If.Implements<IOrderRepository>,
Then.Register().AsSingleInterfaceOfType().UsingPerCallMode())
.Include(If.DecoratedWith<LoggerAttribute>,
Then.Register()
.AsInterface<IDisposable>()
.WithTypeName()
.UsingLifetime<MyLifetimeManager>())
.Exclude(t => t.Name.Contains("Trace"))
.ApplyAutoRegistration();