Created
March 26, 2011 15:05
-
-
Save Itslet/888348 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Web; | |
using Castle.MicroKernel.Registration; | |
using Castle.Windsor; | |
using Castle.MicroKernel.SubSystems.Configuration; | |
using System.Web.Mvc; | |
using CastleDemo.Controllers; | |
namespace CastleDemo.Installers | |
{ | |
public class ControllersInstaller : IWindsorInstaller | |
{ | |
public void Install(IWindsorContainer container, IConfigurationStore store) | |
{ | |
container.Register(FindControllers().Configure(ConfigureControllers())); | |
} | |
private ConfigureDelegate ConfigureControllers() | |
{ | |
return c => c.LifeStyle.Transient; | |
} | |
private BasedOnDescriptor FindControllers() | |
{ | |
return AllTypes.FromThisAssembly() | |
.BasedOn<IController>() | |
.If(Component.IsInSameNamespaceAs<HomeController>()) | |
.If(t => t.Name.EndsWith("Controller")); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment