- Create the following folder structure and files:
-- MyApp.Web (The MVC project)
---- PresentationLogic (folder)
------ Container (folder)
-------- BusinessLogicInstaller.cs
-------- ControllersInstaller.cs
-------- IocContainer.cs
-------- WindsorControllerFactory.cs
-
Add the contents of each file in this Gist to your app. Rename namespace to fit to your application.
-
Call
IocContainer.Setup
fromGlobal.asax.cs
. Example shown in this Gist.
I am having a problem in the ControllersInstaller with "AllTypes" not existing in the current context. Am i missing something?
using Castle.MicroKernel.Registration;
using Castle.MicroKernel.SubSystems.Configuration;
using Castle.Windsor;
namespace Kinetic.Web.Container
{
public class ControllersInstaller : IWindsorInstaller
{
public void Install(IWindsorContainer container, IConfigurationStore store)
{
container.Register(AllTypes.FromThisAssembly()
.Pick().If(t => t.Name.EndsWith("Controller"))
.Configure(configurer => configurer.Named(configurer.Implementation.Name))
.LifestylePerWebRequest());
}
}
}