IoC via DI - Inversion of Control via Dependency Injection with H.Necessaire
H.Necessaire's mechanism for Inversion of Control via Dependency Injection
NuGets
dotnet add package H.Necessaire
Basics
Grouping
Multiple Implementations
Note that registering multiple implementations of the same type will overwrite existing registrations; they will not resolve to an enumeration of the given type.
Dependency Injection
Injecting dependencies into a class is done explicitly by implementing ImADependency.
All in all, the DI mechanism in H.Necessaire is kept very simple, as described above.
Any registration (via .Register<>()) is singleton within the given container.
Transient registrations can also be defined via .RegisterAlwaysNew<>().
There is no scoping concept, but it can be easily achieved by creating a new container wherever needed.
The core dependencies of H.Necessaire are all bundled in HNecessaireDependencyGroup.
Therefore you can simply add them to your container like so:
But note that this is not required when you're using the AppWireup mechanisms or Runtime mechanism, since it's already done by them.