Aiursoft.Scanner.Abstractions
7.0.1
See the version list below for details.
dotnet add package Aiursoft.Scanner.Abstractions --version 7.0.1
NuGet\Install-Package Aiursoft.Scanner.Abstractions -Version 7.0.1
<PackageReference Include="Aiursoft.Scanner.Abstractions" Version="7.0.1" />
paket add Aiursoft.Scanner.Abstractions --version 7.0.1
#r "nuget: Aiursoft.Scanner.Abstractions, 7.0.1"
// Install Aiursoft.Scanner.Abstractions as a Cake Addin #addin nuget:?package=Aiursoft.Scanner.Abstractions&version=7.0.1 // Install Aiursoft.Scanner.Abstractions as a Cake Tool #tool nuget:?package=Aiursoft.Scanner.Abstractions&version=7.0.1
Aiursoft Scanner
An Automatic dependencies management system for ASP.NET Core and powers Aiursoft.
Why this project
The traditional way to add dependencies is:
service.AddScoped<MyScopedDependency>();
Which means that you have to manually inject all dependencies. When you have too many of them, it is possible to make a mistake.
How to use Aiursoft.Scanner
First, install Aiursoft.Scanner
to your ASP.NET Core project from nuget.org:
dotnet add package Aiursoft.Scanner
Add the interface to your class like this:
using Aiursoft.Scanner.Abstractions;
public class MySingletonService : ISingletonDependency
{
}
public class MyScopedService : IScopedDependency
{
}
public class MyTransientService : ITransientDependency
{
}
And just call this in your StartUp.cs
:
using Aiursoft.Scanner;
services.AddScannedDependencies();
That's all! All your dependencies are registered. Just use it like previous before:
public class MyController : Controller
{
private readonly MyScopedService _service;
public MyController(MyScopedService service)
{
_service = service;
}
}
Advanced usage
When you want to register a dependency that implements an abstract, your previous way is:
public class MyClass : IAbstract
{
}
service.AddScoped<IAbstract, MyClass>();
That's fine. But now we want to register this automatically.
Add the dependency interface to your service like this:
public class MyClass : IAbstract, IScopedDependency
{
}
When you are registering all dependencies in your StartUp.cs
, tell us that your project supports your abstract.
services.AddScannedDependencies(typeof(IAbstract));
And you can call it with multiple abstracts:
services.AddScannedDependencies(typeof(IAbstract1), typeof(IAbstract2), typeof(IAbstract3));
That's all! Enjoy!
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net7.0 is compatible. 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. |
-
net7.0
- No dependencies.
NuGet packages (4)
Showing the top 4 NuGet packages that depend on Aiursoft.Scanner.Abstractions:
Package | Downloads |
---|---|
Aiursoft.Scanner
Automatic dependencies management system which powers Aiursoft |
|
Aiursoft.DocGenerator
A tool for generating document for ASP.NET Core. |
|
Aiursoft.CSTools
It contains many useful tools for CSharp developers. |
|
Aiursoft.Canon
Task fire and forget framework |
GitHub repositories
This package is not used by any popular GitHub repositories.