Skip to content

Add support for registrations by convention

Latest
Compare
Choose a tag to compare
@florinc florinc released this 10 Mar 13:43
· 31 commits to master since this release

iQuarc.AppBoot 1.1.0.nupkg available on nuget.org

Registrations into the Dependency Injection Container may also be done by conventions, through the new ConventionRegistrationBehavior.

var conventions = new ConventionRegistrationBehavior();

conventions.ForTypesDerivedFrom<Repository>().ExportInterfaces(x => x.Name.EndsWith("Repository"));
conventions.ForType<InterceptorsResolver>().Export(b => b.AsContractType<IInterceptorsResolver>().WithLifetime(Lifetime.Application));
conventions.ForType<UnitOfWork>().Export(b => b.AsContractType<IUnitOfWork>());

Bootstrapper b = new Bootstrapper(assemblies);
b.AddRegistrationBehavior(conventions);
...