/DD4T.DI.Unity

Unity Dependency Injection for DD4T .NET

Primary LanguageC#Apache License 2.0Apache-2.0

AppVeyor

AppVeyor

dd4t-di-unity

Unity Dependency injection container

Release 2.5

  • Upgraded reference to DD4T.Core

How to

  1. Install Nuget package: Install-Package DD4T.DI.Unity http://www.nuget.org/packages/DD4T.DI.Unity
  2. Add DD4T.DI.Unity namespace to your usings
  3. Call the UseDD4T method on your Unity Microsoft.Practices.Unity.UnityContainer interface.
IUnityContainer container = new UnityContainer();
//set all your custom apllication binding here.

container.UseDD4T();

UseDD4T will Register all default class provided by the DD4T framework.

If you need to override the default classes: (i.e. the DefaultPublicationResovler) Register your class before the method call UseDD4T

IUnityContainer container = new UnityContainer();
//set all your custom apllication binding here.
container.RegisterType<IPublicationResolver, MyCustomPublicationResovler>(new ContainerControlledLifetimeManager());
container.UseDD4T();