StructureMap

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

NServiceBus can be configured to use StructureMap for dependency injection.

Default Usage

busConfiguration.UseContainer<StructureMapBuilder>();

Existing 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

Samples


Last modified