I have one solution which has two projects: MVC and Business
From Castle Windsor: Register components across multiple projects in solution I could tell that all plumbing should be in the MVC layer, so I created an IoC container (in MVC) as such:
public static class IocContainer
{
private static IWindsorContainer _container;
public static void Setup()
{
_container = new WindsorContainer().Install(FromAssembly.This());
}
public static T Resolve<T>()
{
return _container.Resolve<T>();
}
}
I also created an installer in the MVC project:
public class BusinessLogicInstaller : IWindsorInstaller
{
public void Install(IWindsorContainer container, IConfigurationStore store)
{
container.Register(Component.For<IBusinessFacade>()
.ImplementedBy<BusinessFacade>()
.LifestylePerWebRequest());
}
}
Since the intaller knows about the concrete BusinessFacade type, MVC depends on the Business layer (where the BusinessFacade class resides).
Because i also want to use DI in the business layer, how would I access the IoC container from Business project, without creating a cyclic dependency with MVC and Business ?