當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。