Skip to content

Latest commit

 

History

History
31 lines (22 loc) · 1.75 KB

File metadata and controls

31 lines (22 loc) · 1.75 KB

LightInject.Microsoft.DependencyInjection

AppVeyor NuGet GitHub tag

Implements the Microsoft.Extensions.DependencyInjection.Abstractions and makes it possible to create an IServiceProvider that is 100% compatible with the Microsoft.Extensions.DependencyInjection.Specification.Tests.

Note: This package is NOT meant to be used directly with AspNetCore applications. If the target application is an AspNetCore application, use the LightInject.Microsoft.Hosting package instead.

Installing

dotnet add package LightInject.Microsoft.DependencyInjection

Usage

var services = new ServiceCollection();
services.AddTransient<Foo>();
var provider = services.CreateLightInjectServiceProvider();

It is also possible to create an IServiceProvider directly from an IServiceContainer instance.

var container = new ServiceContainer(Options.Default.WithMicrosoftSettings);
var provider = container.CreateServiceProvider();

Note: Make sure that the Options.Default.WithMicrosoftSettings is passed in as options when creating the container. This makes the provider compliant with the default provider from Microsoft.