EasyServiceRegister 2.0.5
See the version list below for details.
dotnet add package EasyServiceRegister --version 2.0.5
NuGet\Install-Package EasyServiceRegister -Version 2.0.5
<PackageReference Include="EasyServiceRegister" Version="2.0.5" />
paket add EasyServiceRegister --version 2.0.5
#r "nuget: EasyServiceRegister, 2.0.5"
// Install EasyServiceRegister as a Cake Addin #addin nuget:?package=EasyServiceRegister&version=2.0.5 // Install EasyServiceRegister as a Cake Tool #tool nuget:?package=EasyServiceRegister&version=2.0.5
Version 2.0.0 has of EasyServiceRegister has some break changes, code has been optimized and other cool stuff has been added!!
How to use it:
- First you will need to install the package in the project where your services implementations will be.
dotnet add package EasyServiceRegister --version 2.0.5 (.netstandard 2.0)
- Then in each service class you must add one of the following class attributes:
RegisterAsSingleton --> It will register your service as Singleton.
RegisterAsScoped --> It will register your service as Scoped.
RegisterAsTransient --> It will register your service as Transcient.
note: Each attribute has a parameter indicating if your service must be registered using TryAdd or just Add, by default this property will be false.
- Finally you must register your services using the following extension method
services.AddServices(params Type[] handlerAssemblyMarkerTypes);
Each handlerAssemblyMarkerTypes must be a type from the assembly where your services are.
Here is an example of a service implementation:
var builder = WebApplication.CreateBuilder(args);
var configuration = builder.Configuration;
// In this case services from two differents assemblies are been registered into DI
builder.Services.AddServices(typeof(DependencyInjection), typeof(Program));
builder.Services.AddEndpointDefinitions(configuration);
var app = builder.Build();
app.ConfigurePipeline();
app.UseEndpointDefinitions();
await app.ApplySeeder();
await app.RunAsync();
[RegisterAsScoped]
public class ProductCommandServices : IProductCommandServices
{
private readonly IApplicationDbContext _context;
private readonly IMapper _mapper;
public ProductCommandServices(IApplicationDbContext context, IMapper mapper)
{
_context = context;
_mapper = mapper;
}
}
[RegisterAsSingleton(useTryAddSingleton: true)]
public class GetCurrentUser
{
public Task<User> GetCurrentUser()
{
...
}
}
Consider the following: In case your service implement an interface to abstract itself, that interface must be the last you implement. Ex.
[RegisterAsScoped]
public class ProductCommandServices : ISomeOtherInterface, IProductCommandServices
{
...
}
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 | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. 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. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.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 |