Klab.Toolkit.DI 2.8.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package Klab.Toolkit.DI --version 2.8.2
                    
NuGet\Install-Package Klab.Toolkit.DI -Version 2.8.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="Klab.Toolkit.DI" Version="2.8.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Klab.Toolkit.DI" Version="2.8.2" />
                    
Directory.Packages.props
<PackageReference Include="Klab.Toolkit.DI" />
                    
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 Klab.Toolkit.DI --version 2.8.2
                    
#r "nuget: Klab.Toolkit.DI, 2.8.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 Klab.Toolkit.DI@2.8.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=Klab.Toolkit.DI&version=2.8.2
                    
Install as a Cake Addin
#tool nuget:?package=Klab.Toolkit.DI&version=2.8.2
                    
Install as a Cake Tool

Klab.Toolkit.DI

In this project I try to implement a simple and lightweight dependency injection toolkit. The toolkit contains helper classes for the following tasks:

  • Generic Factory to resolve dependencies with a key.
  • Register Classes into the factories with a key.

Generic Factory

In most application it exists always a Factory which the client pass a key and then get the correct implementation of the interface. The toolkit contains a generic factory which can be used for this purpose. For the Factory it can be use with some extension methods to register the classes into the factory. The extension methods try always register the factory for the specific interface and if the factory already exists then the class will be added to the factory. The factory can be used as follows:


// classes
public interface IDependency
{
    string Name { get; }
}

public class Dependency1 : IDependency
{
    public string Name => "one";
}

public class Dependency2 : IDependency
{
    public string Name => "two";
}

// Register interfae and a implemetation to the Microsoft built in DI container
services.AddFactoryMethodTransient<IDependency, Dependency1>("one");
services.AddFactoryMethodTransient<IDependency, Dependency2>("two");
service_builder = services.BuildServiceProvider();

IDependencyFactory<IDependeny> factory = service_builder.GetService<IDependencyFactory<IDependeny>>();
IDependency one = factory.GetInstance("one");
IDependency two = factory.GetInstance("two");
IEnumerable<IDependency> all = factory.GetAllInstances();
IEnumerable<string> keys = factory.Keys;

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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.  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 was computed.  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. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
2.10.0 87 8/22/2025
2.9.0 133 8/3/2025
2.8.2 236 5/15/2025
2.8.1 164 4/24/2025
2.8.0 168 4/22/2025
2.7.3 148 4/13/2025
2.7.2 182 4/6/2025
2.7.1 178 4/3/2025
2.7.0 173 4/3/2025
2.6.0 499 3/24/2025
2.5.1 137 3/14/2025
2.5.0 120 2/24/2025
2.4.1 143 10/2/2024
2.4.0 128 10/2/2024
2.3.0 134 10/1/2024
2.2.4 123 9/30/2024
2.2.3 133 9/28/2024
2.2.2 125 9/20/2024
2.2.1 150 9/17/2024
2.2.0 143 9/17/2024
2.1.0 161 8/12/2024
2.0.0 211 12/28/2023
1.0.0 193 5/28/2023
0.3.0 190 5/28/2023
0.2.0 199 5/28/2023
0.1.0 196 5/28/2023