Posted By

nivlam on 06/13/11


Tagged


Versions (?)

MVC - Windsor controller factory


 / Published in: C#
 

  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  

You need to login to post a comment.