This package contains helpers to find assemblies class or interface and register them in the dependency injection container.
==========
- Add nuget package:
Install-Package ServiceCollectionHelpers.AssemblyFinder
- In your application, you can call the extension RegisterClassesOfType to find and register some classes or interfaces :
builder.Services.RegisterClassesOfType<ISomeInterface>();In case of the type is a class, it will register all classes that inherits from the type. In case of the type is an interface, it will register all classes that implements the interface.
By default, all register classes are registered as Transient. But you can override this configuration by using the overload of the method :
builder.Services.RegisterClassesOfType<ISomeInterface>(new RegisterAsOptions()
{
RegisterAs = RegisterAs.Scoped
});You can find more details and samples in the Wiki or in unit tests.
Do not hesitate to check unit tests on the solution. It's a good way to check how transformations are tested.
Also, to get more samples, go to the Wiki.
Do not hesitate to contribute.
If you have any questions, problems or suggestions, create an issue or fork the project and create a Pull Request.