MVC - Windsor controller factory


/ Published in: C#
Save to your folder(s)



Copy this code and paste it in your HTML
  1. public class WindsorControllerFactory : DefaultControllerFactory
  2. {
  3. private readonly IWindsorContainer container;
  4.  
  5. public WindsorControllerFactory(IWindsorContainer container)
  6. {
  7. this.container = container;
  8. }
  9.  
  10. public override void ReleaseController(IController controller)
  11. {
  12. container.Kernel.ReleaseComponent(controller);
  13. }
  14.  
  15. protected override IController GetControllerInstance(RequestContext context, Type controllerType)
  16. {
  17. if (controllerType == null)
  18. base.GetControllerInstance(context, controllerType);
  19.  
  20. return (IController)container.Kernel.Resolve(controllerType);
  21. }
  22. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.