private ControllerContext ControllerContextFactory(RequestContext requestContext, string controllerName, string areaName) { try { IController controller = ControllerBuilder.Current.GetControllerFactory().CreateController(requestContext, controllerName); if (controller == null) { return(null); } if (areaName.HasValue() && !controller.GetType().FullName.Contains("Areas")) { IList <Type> controllerTypes = controllerTypeCache.GetControllerTypes(controllerName) ?? new List <Type>(); Type controllerType = GetControllerByArea(controllerTypes, areaName); controller = (IController)Activator.CreateInstance(controllerType); } return(new ControllerContext(requestContext, controller as ControllerBase)); } catch (Exception) { return(null); } }
public IDictionary <string, IList <MethodInfo> > GetAllActionMethods(RequestContext requestContext, string controllerName) { Guard.IsNotNull(requestContext, "requestContext"); Guard.IsNotNullOrEmpty(controllerName, "controllerName"); Type controllerType = controllerTypeCache.GetControllerTypes(requestContext, controllerName).FirstOrDefault(); return(cache.Get(controllerType.AssemblyQualifiedName, () => GetInternal(controllerType))); }
private ControllerDescriptor ControllerDescriptorFactory(string controllerName, string areaName) { Type controllerType = GetControllerByArea(controllerTypeCache.GetControllerTypes(controllerName), areaName); if (controllerType == null) { return(null); } return(new ReflectedControllerDescriptor(controllerType)); }
public IEnumerable <AuthorizeAttribute> GetAuthorizeAttributes(RequestContext requestContext, string controllerName, string actionName, RouteValueDictionary routeValues) { IEnumerable <AuthorizeAttribute> attributes = null; IList <Type> controllerTypes = controllerTypeCache.GetControllerTypes(controllerName) ?? new List <Type>(); Type controllerType = GetControllerByArea(controllerTypes, routeValues); if (controllerType != null) { var map = cache.Get(controllerType.AssemblyQualifiedName, () => GetInternal(controllerType, actionMethodCache.GetAllActionMethods(controllerType))); map.TryGetValue(actionName, out attributes); } return(attributes ?? new List <AuthorizeAttribute>()); }