StructureMap

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

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

Default Usage

endpointConfiguration.UseContainer<StructureMapBuilder>();

Existing Container Instance

var container = new Container(
    action: expression =>
    {
        expression.For<MyService>()
            .Use(new MyService());
    });
endpointConfiguration.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