di-lite 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package di-lite --version 1.0.0
NuGet\Install-Package di-lite -Version 1.0.0
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="di-lite" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add di-lite --version 1.0.0
#r "nuget: di-lite, 1.0.0"
#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.
// Install di-lite as a Cake Addin
#addin nuget:?package=di-lite&version=1.0.0

// Install di-lite as a Cake Tool
#tool nuget:?package=di-lite&version=1.0.0


DiLite /dɪˈlʌɪt/ is a minimalist, lightweight DI framework. Registrations and resolutions will look very familiar to those accustomed to Autofac.

Build Status Coverage Status Maintainability License: MIT


Create a ContainerBuilder, make the registrations, then build your Container:

var containerBuilder = new ContainerBuilder();
var container = containerBuilder.Build();

Then simply resolve what you need from the Container:

var myInstance = container.Resolve<IMyClass>();


1. Single instance

Each resulution call to the container will create a new instance of the registered type, unless it is specified as a singleton during registration. To register a type as a singleton, just use the AsSingleInstance method:


2. As self

If no alias is specified during the registration of a type, it will be registered as itself.


It can be resolved as:

var myInstance = container.Resolve<MyClass>();

If another alias is specified, but the registration as itself is also needed, the AsSelf method must be used:


3. Multiple registrations for the same alias

Multiple registrations can be made for the same alias:


In this case, the Resolve method will return an instance of MyClassImplementation2 because it was the last one registered for that alias. By using the ResolveAll method, all registrations for the alias will be returned:

IEnumerable<IMyClass> myInstances = container.ResolveAll<IMyClass>();

4. Factory method registrations

Factory methods can also be registered as Func<IContainer, T>:

containerBuilder.RegisterFactoryMethod(container =>
    var dep1 = container.Resolve<IDependency1>();
    var dep2 = container.Resolve<IDependency2>();
    return new MyClass(dep1, dep2);

These registrations can be resolved as their simple type counterparts:

var myInstance = container.Resolve<IMyClass>();
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. 
.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.
  • .NETStandard 2.1

    • 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
1.0.3 445 10/31/2020
1.0.2 385 10/31/2020
1.0.1 424 9/18/2020
1.0.0 432 3/30/2020