EasyServiceRegister 1.0.2
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package EasyServiceRegister --version 1.0.2
NuGet\Install-Package EasyServiceRegister -Version 1.0.2
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.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add EasyServiceRegister --version 1.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: EasyServiceRegister, 1.0.2"
#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.2 // Install EasyServiceRegister as a Cake Tool #tool nuget:?package=EasyServiceRegister&version=1.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
This is a package that makes it easier to register services in your .Net application.
How to use it:
- 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)
- 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.
- 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, last 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 | Versions 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.
-
net6.0
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 | 5,635 | 12/6/2023 |
2.0.8 | 154 | 12/5/2023 |
2.0.7 | 116 | 12/5/2023 |
2.0.6 | 767 | 4/29/2023 |
2.0.5 | 2,610 | 11/26/2022 |
2.0.4 | 316 | 11/23/2022 |
2.0.3 | 345 | 11/20/2022 |
2.0.2 | 320 | 11/19/2022 |
2.0.1 | 302 | 11/19/2022 |
2.0.0 | 312 | 11/19/2022 |
1.0.2 | 2,879 | 5/8/2022 |
1.0.1 | 399 | 5/8/2022 |
1.0.0 | 493 | 1/19/2022 |
0.0.9 | 388 | 1/20/2022 |
0.0.8 | 414 | 1/20/2022 |