Esempio n. 1
0
 protected virtual void OnPostResolveRequestCache(object sender, EventArgs e)
 {
     HttpContextWrapper httpContext = new HttpContextWrapper(HttpContext.Current);
     RouteData routeData = RouteTable.Routes.GetRouteData(httpContext);
     if (null == routeData)
     {
         return;
     }
     RequestContext requestContext = new RequestContext { RouteData = routeData, HttpContext = httpContext };
     IHttpHandler handler = routeData.RouteHandler.GetHttpHandler(requestContext);
     httpContext.RemapHandler(handler); 
 }
 public IController CreateController(RequestContext requestContext, string controllerName)
 {
     string typeName = controllerName + "Controller";
     List<string> namespaces = new List<string>();
     namespaces.AddRange(requestContext.RouteData.Namespaces);
     namespaces.AddRange(ControllerBuilder.Current.DefaultNamespaces);
     foreach (var ns in namespaces)
     {
     string controllerTypeName = string.Format("{0}.{1}", ns, typeName);
     Type controllerType = controllerTypes.FirstOrDefault(type => string.Compare(type.FullName, controllerTypeName, true) == 0);
     if (null != controllerType)
     {
         return (IController)Activator.CreateInstance(controllerType);
     }
     }
     return null;
 }
Esempio n. 3
0
 public void Execute(RequestContext requestContext)
 {
     ControllerContext context = new ControllerContext { RequestContext = requestContext, Controller = this };
     string actionName = requestContext.RouteData.ActionName;
     this.ActionInvoker.InvokeAction(context, actionName);
 }
Esempio n. 4
0
 public MvcHandler(RequestContext requestContext)
 {
     this.RequestContext = requestContext;
 }
Esempio n. 5
0
 public IHttpHandler GetHttpHandler(RequestContext requestContext)
 {
     return new MvcHandler(requestContext);
 }