StructureMap

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

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

Default Usage

Edit
busConfiguration.UseContainer<StructureMapBuilder>();

Existing Container Instance

Edit
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