VoidNone.DependencyInjection
4.1.2
See the version list below for details.
dotnet add package VoidNone.DependencyInjection --version 4.1.2
NuGet\Install-Package VoidNone.DependencyInjection -Version 4.1.2
<PackageReference Include="VoidNone.DependencyInjection" Version="4.1.2" />
<PackageVersion Include="VoidNone.DependencyInjection" Version="4.1.2" />
<PackageReference Include="VoidNone.DependencyInjection" />
paket add VoidNone.DependencyInjection --version 4.1.2
#r "nuget: VoidNone.DependencyInjection, 4.1.2"
#:package VoidNone.DependencyInjection@4.1.2
#addin nuget:?package=VoidNone.DependencyInjection&version=4.1.2
#tool nuget:?package=VoidNone.DependencyInjection&version=4.1.2
VoidNone.DependencyInjection
VoidNone.DependencyInjection is a lightweight .NET dependency injection extension library that supports automatic service registration via attributes. It simplifies the service registration process, improves development efficiency, and is suitable for various .NET application scenarios.
Install
Usage
Service Definition
Define a class as a service
[Transient]
class TransientService { }
[Singleton]
class SingletonService { }
[Scoped]
class ScopedService { }
Using interfaces
interface IBaseService { }
interface IService : IBaseService { }
[Singleton<IService>]
class Service1 : IService { }
// or
[Singleton<IService, IBaseService>]
class Service2 : IService { }
// or
[Singleton(typeof(IService), typeof(IBaseService))]
class Service3 : IService { }
Registering keyed services
[Singleton<IService>("keyName")]
class Service1 : IService { }
// or
[Singleton("keyName", typeof(IService))]
class Service2 : IService { }
Registering Services
// ServiceCollection
services.AddFromAssemblies(typeof(Service1).Assembly)
Extended Service Retrieval Methods
Retrieve all service types, including regular and keyed services
_services.GetAllServiceTypes();
Retrieve all service instances, including regular and keyed services
_services.GetAllServiceInstances();
Retrieve the ServiceProvider for the current HttpContext scope
_services.GetScopedServiceProvider();
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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 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. |
-
net10.0
- No dependencies.
-
net6.0
- No dependencies.
-
net8.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.