PageRenderTime 42ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/src/MM.Bootstrapper/WindsorControllerFactory.cs

#
C# | 35 lines | 24 code | 11 blank | 0 comment | 2 complexity | 6b9406f9c3680815a798f6a493a2ad5f MD5 | raw file
  1. using System;
  2. using System.Web;
  3. using System.Web.Mvc;
  4. using System.Web.Routing;
  5. using Castle.Windsor;
  6. using MM.Web.Controllers;
  7. namespace MM.Bootstrapper
  8. {
  9. public class WindsorControllerFactory : DefaultControllerFactory
  10. {
  11. private IWindsorContainer container;
  12. public WindsorControllerFactory(IWindsorContainer container) {
  13. this.container = container;
  14. }
  15. protected override IController GetControllerInstance(RequestContext requestContext, Type controllerType)
  16. {
  17. if (controllerType != null)
  18. {
  19. return (IController)container.Resolve(controllerType);
  20. }
  21. return base.GetControllerInstance(requestContext, controllerType);
  22. }
  23. }
  24. }