当前位置: 首页>>代码示例>>C#>>正文


C# Mvc.ControllerDescriptor类代码示例

本文整理汇总了C#中System.Web.Mvc.ControllerDescriptor的典型用法代码示例。如果您正苦于以下问题:C# ControllerDescriptor类的具体用法?C# ControllerDescriptor怎么用?C# ControllerDescriptor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ControllerDescriptor类属于System.Web.Mvc命名空间,在下文中一共展示了ControllerDescriptor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetInferredAction

 protected virtual InferredAction GetInferredAction(ControllerDescriptor controllerDescriptor, string actionName) {
     return InferredActions.Current
         .Where(inferred => inferred.Controller == controllerDescriptor.ControllerType)
         .Where( inferred =>
             string.Equals(inferred.ActionName, actionName, StringComparison.CurrentCultureIgnoreCase))
         .FirstOrDefault();
 }
开发者ID:calebjenkins,项目名称:mvcturbine,代码行数:7,代码来源:TurbineActionInvoker.cs

示例2: TaskAsyncActionDescriptor

 /// <summary>
 /// Конструктор, сохраняет нужные данные
 /// </summary>
 /// <param name="methodInfo">данные о вызываемом action'е</param>
 /// <param name="actionName">имя action'а</param>
 /// <param name="controllerDescriptor">дескриптор контроллера</param>
 public TaskAsyncActionDescriptor(
     MethodInfo methodInfo, string actionName, ControllerDescriptor controllerDescriptor)
 {
     _methodInfo = methodInfo;
     _actionName = actionName;
     _controllerDescriptor = controllerDescriptor;
 }
开发者ID:eugeneagafonov,项目名称:ConferenceDemos,代码行数:13,代码来源:TaskAsyncActionDescriptor.cs

示例3: FindAction

        public virtual ActionDescriptor FindAction(ControllerContext controllerContext,
		                                           ControllerDescriptor controllerDescriptor, string actionName)
        {
            // Todo we may want convention here.
            //if (controllerContext.HttpContext.Request.HttpMethod != Verbs.Post)
            //{
            //    return null;
            //}
            var controllerName = controllerContext.RouteData.Values["controller"].ToString().ToLowerInvariant();
            var service = _Registry.GetService(controllerName);
            if (service == null)
            {
                return null;
            }
            var commandAction = service.FindAction(actionName);
            if (commandAction == null || !commandAction.IsCommand())
            {
                return null;
            }
            var commandDescriptor = _Locator.GetInstance<ReflectedCommand>();
            commandDescriptor.SetActionName(actionName);
            commandDescriptor.SetControllerDescriptor(controllerDescriptor);
            commandDescriptor.SetAction(commandAction);
            return commandDescriptor;
        }
开发者ID:ryanohs,项目名称:DynamicServices,代码行数:25,代码来源:CommandActions.cs

示例4: FindAction

        protected override ActionDescriptor FindAction(
			ControllerContext controllerContext, 
			ControllerDescriptor controllerDescriptor, 
			string actionName)
        {
            var action = base.FindAction(controllerContext, controllerDescriptor, actionName);
            if (action != null)
            {
                return action;
            }

            if (typeof(CqrsController).IsAssignableFrom(controllerDescriptor.ControllerType))
            {
                //TODO: cache command types?
                var messagesAssembly = Assembly.Load(new AssemblyName("ECom.Messages"));
                var commandTypes = messagesAssembly.GetTypes()
                                    .Where(t => typeof(ICommand).IsAssignableFrom(t))
                                    .Select(t => new { Name = t.Name, Type = t });

                var command = commandTypes.FirstOrDefault(c => c.Name.Equals(actionName, StringComparison.InvariantCultureIgnoreCase));

                if (command != null)//we have a command action but the action itself is not declared
                {
                    //fallback to cqrs controller generic command action
                    var actionInfo = controllerDescriptor.ControllerType.GetMethod("SubmitCommand").MakeGenericMethod(command.Type);

                    if (actionInfo != null)
                    {
                        return new ReflectedActionDescriptor(actionInfo, actionName, controllerDescriptor);
                    }
                }
            }

            return null;
        }
开发者ID:AlexSugak,项目名称:EComWithCQRS,代码行数:35,代码来源:CqrsControllerActionInvoker.cs

示例5: ReflectedActionDescriptor

        internal ReflectedActionDescriptor(MethodInfo methodInfo, string actionName, ControllerDescriptor controllerDescriptor, bool validateMethod)
        {
            if (methodInfo == null)
            {
                throw new ArgumentNullException("methodInfo");
            }
            if (String.IsNullOrEmpty(actionName))
            {
                throw new ArgumentException(MvcResources.Common_NullOrEmpty, "actionName");
            }
            if (controllerDescriptor == null)
            {
                throw new ArgumentNullException("controllerDescriptor");
            }

            if (validateMethod)
            {
                string failedMessage = VerifyActionMethodIsCallable(methodInfo);
                if (failedMessage != null)
                {
                    throw new ArgumentException(failedMessage, "methodInfo");
                }
            }

            MethodInfo = methodInfo;
            _actionName = actionName;
            _controllerDescriptor = controllerDescriptor;
        }
开发者ID:AndreGleichner,项目名称:aspnetwebstack,代码行数:28,代码来源:ReflectedActionDescriptor.cs

示例6: FindAction

        protected override ActionDescriptor FindAction(ControllerContext controllerContext, ControllerDescriptor controllerDescriptor, string actionName)
        {
            var method = controllerContext.HttpContext.Request.HttpMethod;

            var actionDescriptor = controllerDescriptor.FindAction(controllerContext, method);
            return actionDescriptor;
        }
开发者ID:jwmcpeak,项目名称:ActionControllers,代码行数:7,代码来源:ActionControllerActionInvoker.cs

示例7: GetActionDescriptor

        /// <summary>
        /// Gets the action descriptor and caches it
        /// </summary>
        /// <param name="controllerContext"></param>
        /// <param name="controllerDescriptor"></param>
        /// <param name="actionName"></param>
        /// <returns></returns>
        protected ReflectedActionDescriptor GetActionDescriptor(ControllerContext controllerContext, ControllerDescriptor controllerDescriptor, string actionName)
        {
            var found = _descriptorCache.GetOrAdd(
                controllerDescriptor.UniqueId,
                s => new ReflectedActionDescriptor(
                    controllerContext.Controller.GetType().GetMethods()
                        .First(x => x.Name == actionName &&
                                    x.GetCustomAttributes(typeof(NonActionAttribute), false).Any() == false),
                    actionName,
                    controllerDescriptor));

            //check if the action name matches, it won't if the user has changed the action name in umbraco, if this occurs we need to refresh the cache
            if (!found.ActionName.InvariantEquals(actionName))
            {
                var newDescriptor = new ReflectedActionDescriptor(
                    controllerContext.Controller.GetType().GetMethods()
                        .First(x => x.Name == actionName &&
                                    x.GetCustomAttributes(typeof (NonActionAttribute), false).Any() == false),
                    actionName,
                    controllerDescriptor);

                _descriptorCache.TryUpdate(controllerDescriptor.UniqueId, newDescriptor, found);

                found = newDescriptor;
            }

            return found;
        }
开发者ID:ClaytonWang,项目名称:Articulate,代码行数:35,代码来源:TagsControllerActionInvoker.cs

示例8: FindAction

        protected override ActionDescriptor FindAction(ControllerContext controllerContext, ControllerDescriptor controllerDescriptor, string actionName)
        {
            var ad = base.FindAction(controllerContext, controllerDescriptor, actionName);

            //now we need to check if it exists, if not we need to return the Index by default
            if (ad == null)
            {
                if (controllerContext.RouteData.DataTokens.ContainsKey("__virtualnodefinder__"))
                {
                    var virtualNode = controllerContext.RouteData.DataTokens["__virtualnodefinder__"] as IPublishedContent;
                    if (virtualNode != null)
                    {
                        var action = controllerContext.RouteData.GetRequiredString("action");

                        var categoryUrl = virtualNode.GetPropertyValue<string>("categoriesUrlName");
                        if (action.InvariantEquals(categoryUrl))
                        {
                            return GetActionDescriptor(controllerContext, controllerDescriptor, "Categories");
                        }

                        var tagsUrl = virtualNode.GetPropertyValue<string>("tagsUrlName");
                        if (action.InvariantEquals(tagsUrl))
                        {
                            return GetActionDescriptor(controllerContext, controllerDescriptor, "Tags");
                        }
                    }
                }
            }
            return ad;
        }
开发者ID:ClaytonWang,项目名称:Articulate,代码行数:30,代码来源:TagsControllerActionInvoker.cs

示例9: GetControllerDetails

 public string GetControllerDetails(ControllerDescriptor controllerDescriptor, RequestContext requestContext)
 {
     var template = new ControllerDetails
     {
         Model = GetControllerModel(controllerDescriptor, requestContext)
     };
     return template.TransformText();
 }
开发者ID:sreeramaraju,项目名称:CodeHaacks,代码行数:8,代码来源:ControllerDetailer.cs

示例10: RegistrySelector

        protected RegistrySelector(ActionDescriptor actionDescriptor, ControllerDescriptor controllerDescriptor, ControllerContext controllerContext)
        {
            ActionDescriptor = actionDescriptor;
            ControllerDescriptor = controllerDescriptor;
            ControllerContext = controllerContext;

            if (ControllerContextIsValid()) RegisterControllerRequestData(ControllerContext.HttpContext.Request);
            if (ControllerRouteDataIsValid()) RegisterControllerRouteData(ControllerContext.RouteData);
        }
开发者ID:Grinderofl,项目名称:FluentMvc,代码行数:9,代码来源:RegistrySelector.cs

示例11: GetActionMapping

 public virtual ILookup<string, ApiActionDescriptor> GetActionMapping(ControllerDescriptor controllerDescriptor)
 {
     if (controllerDescriptor == null)
     {
         throw Error.ArgumentNull("controllerDescriptor");
     }
     //return this.GetInternalSelector(controllerDescriptor).GetActionMapping();
     throw new NotImplementedException();
 }
开发者ID:dax70,项目名称:MvcApi,代码行数:9,代码来源:ApiControllerActionSelector.cs

示例12: FindAction

            protected override ActionDescriptor FindAction(ControllerContext controllerContext, ControllerDescriptor controllerDescriptor, string actionName) {
                if (actionName == restActionToken) {
                    // cleanup the restActionToken we set earlier
                    controllerContext.RequestContext.RouteData.Values["action"] = null;

                    List<ActionDescriptor> matches = new List<ActionDescriptor>();
                    foreach (ActionDescriptor ad in controllerDescriptor.GetCanonicalActions()) {
                        object[] acceptVerbs = ad.GetCustomAttributes(typeof(AcceptVerbsAttribute), false);
                        if (acceptVerbs.Length > 0) {
                            foreach (object o in acceptVerbs) {
                                AcceptVerbsAttribute ava = o as AcceptVerbsAttribute;
                                if (ava != null) {
                                    if (ava.Verbs.Contains(controllerContext.HttpContext.Request.GetHttpMethodOverride().ToUpperInvariant())) {
                                        matches.Add(ad);
                                    }
                                }
                            }
                        }
                    }
                    switch (matches.Count) {
                        case 0:
                            break;
                        case 1:
                            ActionDescriptor ad = matches[0];
                            actionName = ad.ActionName;
                            controllerContext.RequestContext.RouteData.Values["action"] = actionName;
                            return ad;
                        default:
                            StringBuilder matchesString = new StringBuilder(matches[0].ActionName);
                            for (int index = 1; index < matches.Count; index++) {
                                matchesString.Append(", ");
                                matchesString.Append(matches[index].ActionName);
                            }
                            return new ResourceErrorActionDescriptor(
                                controllerDescriptor,
                                HttpStatusCode.Conflict,
                                String.Format(
                                    CultureInfo.CurrentCulture,
                                    MvcResources.ResourceControllerFactory_ConflictingActions,
                                    controllerDescriptor.ControllerName,
                                    matchesString.ToString()
                                )
                            );
                    }
                }
                return base.FindAction(controllerContext, controllerDescriptor, actionName) ??
                    new ResourceErrorActionDescriptor(
                        controllerDescriptor,
                        HttpStatusCode.NotFound,
                        String.Format(
                            CultureInfo.CurrentCulture,
                            MvcResources.ResourceControllerFactory_NoActions,
                            controllerDescriptor.ControllerName
                        )
                    );
            }
开发者ID:adrianvallejo,项目名称:MVC3_Source,代码行数:56,代码来源:ResourceControllerFactory.cs

示例13: FindAction

        protected override ActionDescriptor FindAction(ControllerContext controllerContext, ControllerDescriptor controllerDescriptor, string actionName)
        {
            var result = base.FindAction(controllerContext, controllerDescriptor, actionName);
            if (result == null)
            {
                return new NotFoundActionDescriptor();
            }

            return result;
        }
开发者ID:andrewdavey,项目名称:NotFoundMvc,代码行数:10,代码来源:NotFoundAsyncControllerActionInvoker.cs

示例14: FixtureSetUp

        public void FixtureSetUp()
        {
            _baseControllerContext = new ControllerContext {Controller = new TestController()};

            _baseMethodInfo = TestController.GetAction1MethodInfo<TestController>();
            _actionName = _baseMethodInfo.Name;

            _controllerDescriptor = new Mock<ControllerDescriptor>().Object;
            _reflectedActionDescriptor = new ReflectedActionDescriptor(_baseMethodInfo, _actionName, _controllerDescriptor);
        }
开发者ID:RoymanJing,项目名称:Autofac,代码行数:10,代码来源:AutofacFilterProviderFixture.cs

示例15: FindAction

 /// <summary>
 /// Finds the action for the controller, if not it is inferred.
 /// </summary>
 /// <param name="controllerContext"></param>
 /// <param name="controllerDescriptor"></param>
 /// <param name="actionName"></param>
 /// <returns></returns>
 protected override ActionDescriptor FindAction(ControllerContext controllerContext,
     ControllerDescriptor controllerDescriptor, string actionName)
 {
     var foundAction = base.FindAction(controllerContext, controllerDescriptor, actionName);
     if (foundAction == null) {
         InferredAction inferredAction = GetInferredAction(controllerDescriptor, actionName);
         foundAction = new InferredActionDescriptor(actionName, controllerDescriptor, inferredAction);
     }
     return foundAction;
 }
开发者ID:runxc1,项目名称:mvcturbine,代码行数:17,代码来源:TurbineActionInvoker.cs


注:本文中的System.Web.Mvc.ControllerDescriptor类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。