VoidNone.DependencyInjection 4.1.2

There is a newer version of this package available.
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
                    
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="VoidNone.DependencyInjection" Version="4.1.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="VoidNone.DependencyInjection" Version="4.1.2" />
                    
Directory.Packages.props
<PackageReference Include="VoidNone.DependencyInjection" />
                    
Project file
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 VoidNone.DependencyInjection --version 4.1.2
                    
#r "nuget: VoidNone.DependencyInjection, 4.1.2"
                    
#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 VoidNone.DependencyInjection@4.1.2
                    
#: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=VoidNone.DependencyInjection&version=4.1.2
                    
Install as a Cake Addin
#tool nuget:?package=VoidNone.DependencyInjection&version=4.1.2
                    
Install as a Cake Tool

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

Nuget

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • 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.

Version Downloads Last Updated
4.2.0 76 3/4/2026
4.1.3 85 3/2/2026
4.1.2 101 2/15/2026
4.1.1 101 2/13/2026