Prashant.AutoServiceInjection
6.0.1
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 Prashant.AutoServiceInjection --version 6.0.1
NuGet\Install-Package Prashant.AutoServiceInjection -Version 6.0.1
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="Prashant.AutoServiceInjection" Version="6.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Prashant.AutoServiceInjection --version 6.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Prashant.AutoServiceInjection, 6.0.1"
#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 Prashant.AutoServiceInjection as a Cake Addin #addin nuget:?package=Prashant.AutoServiceInjection&version=6.0.1 // Install Prashant.AutoServiceInjection as a Cake Tool #tool nuget:?package=Prashant.AutoServiceInjection&version=6.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Auto Service Injection
A automated service injection for DotNet.
Supported
Tested on .Net6 Only .Net6, .Net5 is supported.
Architectural pattern
There are two ways of performing automated dependency injections.
- Old style, where service is explicitly marked to interface with service type to do dependency injection.
- New Style, where interface is marked with contact and service is marked with serivce type.
New style of standard implies one to one model where a single contract can only have a single service. In this model, the development of a project will faster and quicker. Prefer new style.
New style
In Program.cs
var builder = WebApplication.CreateBuilder(args);
...
...
builder.Services.AutoRegisterServices(); // Add this to enable Auto Dependencies injection. By default old style is disabled.
...
...
Service model
using System;
[Service(ServiceType.Transient)]
public class TheDemoService : IDemo
Contract model
using System;
[Contract]
public interface IDemo
Old Style
To enable old style in .Net 6 and .Net 5
builder.Services.AutoRegisterServices(opt => {
opt.EnableBackwardCompatibility = true;
});
using Prashant.AutoServiceInjection;
[Service(typeof(IDemo),ServiceType.Transient)]
public class TheDemoService : IDemo
In startup.cs
using Prashant.AutoServiceInjection;
public void ConfigureServices(IServiceCollection services)
{
....
....
Service.AutoRegister(services,true); //That's all
}
For issues and Sugguestions
Ping me @ https://twitter.com/Prashant_Elango or Drop a mail to software-devision@froze.in
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. net5.0-windows was computed. 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.
-
net5.0
- Microsoft.Extensions.DependencyInjection (>= 5.0.1)
-
net6.0
- Microsoft.Extensions.DependencyInjection (>= 6.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.