Skip to content

WilliamBZA/NServicebus.SimpleInjector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NServiceBus.SimpleInjector

NOTE: Starting with NServiceBus version 8, the dependency injection container adapter packages are no longer required. NServiceBus directly supports the Microsoft.Extensions.DependencyInjection.Abstractions model and third party containers can be integrated using the externally-managed container mode. Visit the dependency injection upgrade guide for further information.

NServiceBus can be configured to use Simple Injector for dependency injection.

Default usage

endpointConfiguration.UseContainer<SimpleInjectorBuilder>();

Using an existing container

var container = new Container();
container.Options.DefaultScopedLifestyle = new AsyncScopedLifestyle();
container.Options.AllowOverridingRegistrations = true;
container.Options.AutoWirePropertiesImplicitly();

container.Register(
    instanceCreator: () =>
    {
        return new MyService
        {
            Property = "Created outside"
        };
    },
    lifestyle: Lifestyle.Scoped);

endpointConfiguration.UseContainer<SimpleInjectorBuilder>(
    customizations =>
    {
        customizations.UseExistingContainer(container);
    });

DependencyLifecycle Mapping

DependencyLifecycle maps to Simple Injector lifestyles as follows:

DependencyLifecycle Simple Injector lifestyle
InstancePerCall Transient
InstancePerUnitOfWork Scoped
SingleInstance Singleton

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages