Unity

Project Hosting
NuGet NServiceBus.Unity (4.x)
Target NServiceBus Version: 4.x
Standard support for version 4.x of NServiceBus has expired. For more information see our Support Policy.

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

Default Usage

configure.UnityBuilder();

Existing Container Instance

var container = new UnityContainer();
container.RegisterInstance(new MyService());
configure.UnityBuilder(container);

DependencyLifecycle Mapping

The DependencyLifecycle map to Unity in the following way.

DependencyLifecycleUnity Equivalent
InstancePerCallTransient Lifetime Manager
InstancePerUnitOfWorkHierarchical Lifetime Manager
SingleInstanceContainer Controlled Lifetime Manager

Last modified