StructureMap

Project Hosting
NuGet Package NServiceBus.StructureMap (7-pre)
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 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

Samples


Last modified