PageRenderTime 22ms CodeModel.GetById 14ms app.highlight 4ms 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
 1using System;
 2using System.Web;
 3using System.Web.Mvc;
 4using System.Web.Routing;
 5using Castle.Windsor;
 6using MM.Web.Controllers;
 7
 8namespace MM.Bootstrapper
 9{
10    public class WindsorControllerFactory : DefaultControllerFactory
11    {
12        private IWindsorContainer container;
13
14        public WindsorControllerFactory(IWindsorContainer container) {
15            
16            this.container = container;
17        }
18
19        protected override IController GetControllerInstance(RequestContext requestContext, Type controllerType)
20        {
21
22            if (controllerType != null)
23            {
24                
25                return (IController)container.Resolve(controllerType);
26
27            }
28
29
30            return base.GetControllerInstance(requestContext, controllerType);
31        }
32
33        
34    }
35}