Install-Package ExistsForAll.Shepherd.SimpleInjector
SimpleInjector is a great IoC Container, over the years it became my go to DI for every project.
Thus we've developed methodologies to register infrastructure and domain services quickly.
Shepherd
should act as your Composition Root in your application startup.
- Getting started
- SimpleInjector Configuration
- Assemblies
- Modules
- Auto-Registration
var shepherd = new Shepherd();
var container = shepherd.AddPublicTypesAssemblies(Assemblies)
.AddModule(LoggingModule, DataAccessModule, ConfigurationModule)
.Herd();
Shepherd will gather all the types from the given assemblies (all or only public), iterate over all the modules by order of insertion and auto-register all remaining domain services. The return value from the Herd()
method is SimpleInjector
container.
- The first thing
Shepherd
does after validation and configuration is to gather all the types from the given assemblies. - Then
Shepherd
Will iterate over all theModules
in the order of insertion, after thatShepherd
will index. Shepherd
will index all interfaces to matching implementation and will register them as explained in the Auto-Registration section.