Castle Windsor

Project Hosting
NuGet Package NServiceBus.CastleWindsor (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 Castle Windsor as a dependency injection container.

Default Usage

endpointConfiguration.UseContainer<WindsorBuilder>();

Existing Container Instance

var container = new WindsorContainer();
var registration = Component.For<MyService>()
    .Instance(new MyService());
container.Register(registration);
endpointConfiguration.UseContainer<WindsorBuilder>(
    customizations: customizations =>
    {
        customizations.ExistingContainer(container);
    });

DependencyLifecycle Mapping

The DependencyLifecycle map to Castle LifestyleType in the following way.

DependencyLifecycleCastle LifestyleType
InstancePerCallTransient
InstancePerUnitOfWorkScoped
SingleInstanceSingleton

Samples


Last modified