StructureMap

Project Hosting
NuGet NServiceBus.StructureMap (5.x)
Target NServiceBus Version: 5.x

NServiceBus can be configured to use StructureMap as a dependency injection container.

Default Usage

busConfiguration.UseContainer<StructureMapBuilder>();

Existing Container Instance

var container = new Container(
    action: expression =>
    {
        expression.For<MyService>()
            .Use(new MyService());
    });
busConfiguration.UseContainer<StructureMapBuilder>(
    customizations: customizations =>
    {
        customizations.ExistingContainer(container);
    });

DependencyLifecycle Mapping

The DependencyLifecycle map to StructureMap Lifecycle in the following way.

DependencyLifecycleStructureMap Lifecycle
InstancePerCallAlwaysUnique
InstancePerUnitOfWorkContainerScoped
SingleInstanceSingleton

Last modified