Quick.AutoInject
1.0.1
dotnet add package Quick.AutoInject --version 1.0.1
NuGet\Install-Package Quick.AutoInject -Version 1.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="Quick.AutoInject" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Quick.AutoInject" Version="1.0.1" />
<PackageReference Include="Quick.AutoInject" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Quick.AutoInject --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Quick.AutoInject, 1.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.
#:package Quick.AutoInject@1.0.1
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Quick.AutoInject&version=1.0.1
#tool nuget:?package=Quick.AutoInject&version=1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
๐งฉ Quick.AutoInject
Simplifies dependency injection registration in ASP.NET Core using attributes โ no boilerplate in Program.cs required.
๐ฆ Installation
dotnet add package Quick.AutoInject
โ๏ธ Configure in Program.cs
using Quick.AutoInject;
builder.Services.AddAutoInject();
๐ Usage
Add one of the following attributes to your class depending on the lifetime you need:
| Attribute | Lifetime |
|---|---|
[ScopedService] |
Scoped |
[TransientService] |
Transient |
[SingletonService] |
Singleton |
using Quick.AutoInject;
[ScopedService]
public class MyClass : IMyClass { }
[TransientService]
public class MyClass { }
[SingletonService]
public class MyClass { }
Then inject and use them the traditional way:
public class YourController : ControllerBase
{
private readonly MyClass _myClass;
private readonly IMyClass _iMyClass;
public YourController(MyClass myClass, IMyClass iMyClass)
{
_myClass = myClass;
_iMyClass = iMyClass;
}
[HttpPost]
public async Task<IActionResult> Create([FromBody] MyCommand command)
{
var response = await _myClass.Create(command);
return Ok(response);
}
}
๐ค Contributing
Have a suggestion or found a bug? Feel free to:
- ๐ง Contact me at gfmendoza.27@outlook.com
- ๐ Open an issue on GitHub
๐ค Author
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
-
net8.0
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.