Microsoft.Extensions.DependencyInjection

Source
NuGet Package NServiceBus.MSDependencyInjection (1-pre) | License
This is a community maintained project. License and support are independent of Particular Software.
Target NServiceBus Version: 7.x
This page targets a pre-release version and is subject to change prior to the final release.

NServiceBus can be configured to use Microsoft.Extensions.DependencyInjection for dependency injection.

Default usage

public void ConfigureServices(IServiceCollection services)
{
    // register any services to IServiceCollection

    endpointConfiguration.UseContainer<ServicesBuilder>(customizations =>
    {
        customizations.ExistingServices(services);
    });
}

Dependency Lifecycle mapping

The dependency lifecycle maps in the following way.

DependencyLifecycleMicrosoft.Extensions.DependencyInjection Equivalent
InstancePerCallServiceLifetime.Transient
InstancePerUnitOfWorkServiceLifetime.Scoped
SingleInstanceServiceLifetime.Singleton

Samples


Last modified