bilpor (1) [Avatar] Offline
#1
I cannot find an example (not obvious) about how to place Unity in this type of project so that it extends the container of the parent. e.g. An MVC project using DI makes a reference to the dll generated by the Project library and I want to expose my interfaces to the calling app.

I found a reference on the Microsoft practises website and it suggests something like:

public class MyUnityExtension : UnityContainerExtension
{
//unity binding goes here etc
protected override void Initialize()
{
Container.RegisterType<Interface1, class1>(new ContainerControlledLifetimeManager());
Container.RegisterType<Interface2, class2>(new ContainerControlledLifetimeManager());
}
}

public class Bootstrapper : UnityBootstrapper
{
protected override void ConfigureContainer()
{
base.ConfigureContainer();

Container.AddNewExtension<MyUnityExtension>();
}
}

I cannot see this type of thing anywhere in the book and The implementation of the UnityBootStrapper class on my class BootStrapper seems to no linger exist even though its declared in https://msdn.microsoft.com/en-us/library/microsoft.practices.composite.unityextensions.unitybootstrapper.aspx

So my question is with the latest version of unity how do I extend the parent apps container with the ones in my dll?