NetCore.AutoRegisterDi 2.1.0

Extension method to find/register classes in an assembly into Microsoft.Extensions.DependencyInjection

Install-Package NetCore.AutoRegisterDi -Version 2.1.0
dotnet add package NetCore.AutoRegisterDi --version 2.1.0
<PackageReference Include="NetCore.AutoRegisterDi" Version="2.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add NetCore.AutoRegisterDi --version 2.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

NetCore.AutoRegisterDi

This NuGet library contains an extension method to scan an assemby and register all the non-generic public classes (see excluded class types) against their implemented interfaces(s) into the Microsoft.Extensions.DependencyInjection dependency injection provider.

I have written a simple version of AutoFac's RegisterAssemblyTypes method that works directly with Microsoft's DI provider. Here are an example of me using this with ASP.NET Core.

Version 2.0.0 update: New attributes for defining the ServiceLifetime of your classes, e.g. adding the [RegisterAsScoped] attribute to a class will mean its ServiceLifetime in the DI will be set to Scoped. Added by Fedor Zhekov (GitHub @ZFi88).

Version 2.1.0 update: Added ability ignore an interface, plus added ISerializable interface to list of ignored interfaces and outputs results so that you can check it is registering the correct things.

See README file for documentation or this article for an overvew.

NetCore.AutoRegisterDi

This NuGet library contains an extension method to scan an assemby and register all the non-generic public classes (see excluded class types) against their implemented interfaces(s) into the Microsoft.Extensions.DependencyInjection dependency injection provider.

I have written a simple version of AutoFac's RegisterAssemblyTypes method that works directly with Microsoft's DI provider. Here are an example of me using this with ASP.NET Core.

Version 2.0.0 update: New attributes for defining the ServiceLifetime of your classes, e.g. adding the [RegisterAsScoped] attribute to a class will mean its ServiceLifetime in the DI will be set to Scoped. Added by Fedor Zhekov (GitHub @ZFi88).

Version 2.1.0 update: Added ability ignore an interface, plus added ISerializable interface to list of ignored interfaces and outputs results so that you can check it is registering the correct things.

See README file for documentation or this article for an overvew.

Release Notes

- New feature: IgnoreThisInterface method adds a interface to its interface ignore list.
     - Improvement: Added ISerializable interface to the default interface ignore list (IDisposable is already in base ignore list)
     - Improvement: You can use muliple have Where methods to filter out classes
     - Improvement: Returns a list of the classes/interfaces registered with the DI provider (useful for debugging)

NuGet packages (6)

Showing the top 5 NuGet packages that depend on NetCore.AutoRegisterDi:

Package Downloads
Relay.Microservices
A microservice framework built for .NET Core
Relay.Microservices.Testing
A microservice testing framework built for .NET Core
Relay.Core.Plugins.Microservices
Plugins available for the Core framework
Relay.Core.Microservices.Testing
A microservice testing framework built for .NET Core
Relay.Core.Microservices
A microservice framework built for .NET Core

GitHub repositories (2)

Showing the top 2 popular GitHub repositories that depend on NetCore.AutoRegisterDi:

Repository Stars
JonPSmith/PermissionAccessControl2
Version 2 of example application to go with articles on feature and data authorization
JonPSmith/EfCore.GenericBizRunner
Library to run business logic when using Entity Framework Core for database accesses

Version History

Version Downloads Last updated
2.1.0 1,835 10/6/2020
2.0.0 36,978 5/9/2020
1.1.0 152,587 8/26/2019
1.0.0 110,851 6/16/2018