EasyServiceRegister 2.0.6

There is a newer version of this package available.
See the version list below for details.
dotnet add package EasyServiceRegister --version 2.0.6
NuGet\Install-Package EasyServiceRegister -Version 2.0.6
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="2.0.6" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add EasyServiceRegister --version 2.0.6
#r "nuget: EasyServiceRegister, 2.0.6"
#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=2.0.6

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

EasyServiceRegister 2.x.x - A easy service registration library

EasyServiceRegister is a library that simplifies the process of registering services with the .NET Core Dependency Injection framework. With version 2.x.x, we have introduced breaking changes, optimized the code, and added new features.

More Details below!!

How to use it:

  1. Install the EasyServiceRegister package in your project:
dotnet add package EasyServiceRegister --version 2.0.6 (.netstandard 2.0)
  1. Add the appropriate class attribute to your service class to indicate how it should be registered with DI:
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: You can use an optional parameter (useTryAddSingleton,useTryAddScopped or useTryAddTranscient) with the attribute to indicate whether to use TryAdd or Add when registering the service with DI.

  1. Register your services by calling the AddServices extension method on the IServiceCollection instance in your Startup.cs or Program.cs file:
services.AddServices(params Type[] handlerAssemblyMarkerTypes);

//Example:
services.AddServices(typeof(AssemblyContainingService), typeof(AnotherAssemblyContainingService));

This method takes an array of marker types that indicate which assemblies to scan for service implementations.

In case your service class implements an interface to abstract itself, the interface must be the last interface implemented.

##Example

Here is an example of a service implementation that registers itself as a scoped service:

[RegisterAsScoped]
public class ProductCommandServices : IProductCommandServices
{
    private readonly IApplicationDbContext _context;
    private readonly IMapper _mapper;

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

And here is an example of a service that registers itself as a singleton service using 'TryAddSingleton'

[RegisterAsSingleton(useTryAddSingleton: true)]
public class GetCurrentUser
{
  public Task<User> GetCurrentUser()
   {
     ...
   }
}

With EasyServiceRegister, you can simplify your code by eliminating the need for huge extension methods and a cluttered Startup class.

Product 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. 
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