Unity Dependency injection container
- Upgraded reference to DD4T.Core
- Install Nuget package:
Install-Package DD4T.DI.Unity
http://www.nuget.org/packages/DD4T.DI.Unity - Add
DD4T.DI.Unity
namespace to your usings - Call the
UseDD4T
method on your UnityMicrosoft.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();