EasyServiceRegister 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package EasyServiceRegister --version 1.0.0
NuGet\Install-Package EasyServiceRegister -Version 1.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="EasyServiceRegister" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add EasyServiceRegister --version 1.0.0
#r "nuget: EasyServiceRegister, 1.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install EasyServiceRegister as a Cake Addin
#addin nuget:?package=EasyServiceRegister&version=1.0.0

// Install EasyServiceRegister as a Cake Tool
#tool nuget:?package=EasyServiceRegister&version=1.0.0

This is a package that makes it easier to register services in your .Net application.

How to use it:

  1. First you will need to install the package in the project where your services implementations will be.
Install-Package EasyServiceRegister -Version 0.0.8  (for .Net Core 3.1 projects)
Install-Package EasyServiceRegister -Version 0.0.9  (for .Net 5 projects)
Install-Package EasyServiceRegister -Version 1.0.0  (for .Net 6 projects)
  1. Then in each service class you must implement one of the following interfaces:
IRegisterAsSingleton  --> It will register your service as Singleton.
IRegisterAsScoped     --> It will register your service as Scoped.
IRegisterAsTranscient --> It will register your service as Transcient.
  1. Finally in your Startup class or Program you must add the next extension method:
services.AddServices(new List<string> { "Infrastructure" });

The method receives a list of project names where your services implementations are.

Here is an example of a service implementation:

public class ProductCommandServices : IProductCommandServices, IRegisterAsScoped
{
    private readonly IApplicationDbContext _context;
    private readonly IMapper _mapper;

    public ProductCommandServices(IApplicationDbContext context, IMapper mapper)
    {
        _context = context;
        _mapper = mapper;
    }
}

Consider the following:

* First interface must always be the service abstraction, second one must be the corresponding Easy Service Register interface. 
  (Check the example)

* The abstractions must be in a different project than the implementations. (something like, Application and Infrastructure)

And that's it!! No more loaded Startup classes or huge extension methods registering services in your code. 😃

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.0.9 2,804 12/6/2023
2.0.8 135 12/5/2023
2.0.7 98 12/5/2023
2.0.6 748 4/29/2023
2.0.5 2,549 11/26/2022
2.0.4 294 11/23/2022
2.0.3 326 11/20/2022
2.0.2 299 11/19/2022
2.0.1 275 11/19/2022
2.0.0 294 11/19/2022
1.0.2 2,858 5/8/2022
1.0.1 372 5/8/2022
1.0.0 472 1/19/2022
0.0.9 369 1/20/2022
0.0.8 385 1/20/2022