Castle Windsor

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

NServiceBus can be configured to use Castle Windsor for dependency injection.

Default Usage

busConfiguration.UseContainer<WindsorBuilder>();

Existing Instance

var container = new WindsorContainer();
var registration = Component.For<MyService>()
    .Instance(new MyService());
container.Register(registration);
busConfiguration.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