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


C# ActionDescriptor类代码示例

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


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

示例1: ActionContext

 /// <summary>
 /// Creates a new <see cref="ActionContext"/>.
 /// </summary>
 /// <param name="httpContext">The <see cref="Http.HttpContext"/> for the current request.</param>
 /// <param name="routeData">The <see cref="AspNet.Routing.RouteData"/> for the current request.</param>
 /// <param name="actionDescriptor">The <see cref="Abstractions.ActionDescriptor"/> for the selected action.</param>
 public ActionContext(
     HttpContext httpContext,
     RouteData routeData,
     ActionDescriptor actionDescriptor)
     : this(httpContext, routeData, actionDescriptor, new ModelStateDictionary())
 {
 }
开发者ID:huoxudong125,项目名称:Mvc,代码行数:13,代码来源:ActionContext.cs

示例2: Accept_RejectsActionMatchWithMissingParameter

        public void Accept_RejectsActionMatchWithMissingParameter()
        {
            // Arrange
            var action = new ActionDescriptor();
            action.Parameters = new List<ParameterDescriptor>()
            {
                new ParameterDescriptor()
                {
                    BindingInfo = new BindingInfo()
                    {
                      BindingSource = (new FromUriAttribute()).BindingSource,
                    },
                    Name = "id",
                    ParameterType = typeof(int),
                },
            };

            var constraint = new OverloadActionConstraint();

            var context = new ActionConstraintContext();
            context.Candidates = new List<ActionSelectorCandidate>()
            {
                new ActionSelectorCandidate(action, new [] { constraint }),
            };

            context.CurrentCandidate = context.Candidates[0];
            context.RouteContext = CreateRouteContext();

            // Act & Assert
            Assert.False(constraint.Accept(context));
        }
开发者ID:AndersBillLinden,项目名称:Mvc,代码行数:31,代码来源:OverloadActionConstraintTest.cs

示例3: InvokeAction

        public IActionResult InvokeAction(Controller controller, ActionDescriptor actionDescriptor)
        {
            var methodWithIntParameter =
                controller.GetType()
                    .GetMethods()
                    .FirstOrDefault(
                        x =>
                        x.Name.ToLower() == actionDescriptor.ActionName.ToLower() && x.GetParameters().Length == 1
                        && x.GetParameters()[0].ParameterType == typeof(string)
                        && x.ReturnType == typeof(IActionResult));
            if (methodWithIntParameter == null)
            {
                throw new HttpNotFoundException(
                    string.Format(
                        "Expected method with signature IActionResult {0}(string) in class {1}",
                        actionDescriptor.ActionName,
                        actionDescriptor.ControllerName));
            }

            try
            {
                var actionResult =
                    (IActionResult)methodWithIntParameter.Invoke(controller, new object[] { actionDescriptor.Parameter });
                return actionResult;
            }
            catch (TargetInvocationException ex)
            {
                throw ex.InnerException;
            }
        }
开发者ID:exploitx3,项目名称:HighQualityCode,代码行数:30,代码来源:ActionInvoker.cs

示例4: InvokeAction

        public IActionResult InvokeAction(Controller controller, ActionDescriptor actionDescriptor)
        {
            /*
             * Child processes that use such C run-time functions as printf() and fprintf() can behave poorly when redirected.
             * The C run-time functions maintain separate IO buffers. When redirected, these buffers might not be flushed immediately after each IO call.
             * As a result, the output to the redirection pipe of a printf() call or the input from a getch() call is not flushed immediately and delays, sometimes-infinite delays occur.
             * This problem is avoided if the child process flushes the IO buffers after each call to a C run-time IO function.
             * Only the child process can flush its C run-time IO buffers. A process can flush its C run-time IO buffers by calling the fflush() function.
             */
            var methodWithIntParameter = controller.GetType()
                                          .GetMethods()
                                          .FirstOrDefault(x => x.Name.ToLower() == actionDescriptor.ActionName.ToLower() &&
                                                               x.GetParameters().Length == 1 &&
                                                               x.GetParameters()[0].ParameterType == typeof(string) &&
                                                               x.ReturnType == typeof(IActionResult));
            if (methodWithIntParameter == null)
            {
                throw new HttpNotFoundException(
                    string.Format(
                        "Expected method with signature IActionResult {0}(string) in class {1}Controller",
                        actionDescriptor.ActionName,
                        actionDescriptor.ControllerName));
            }

            try
            {
                var actionResult = (IActionResult)
                    methodWithIntParameter.Invoke(controller, new object[] { actionDescriptor.Parameter });
                return actionResult;
            }
            catch (TargetInvocationException ex)
            {
                throw ex.InnerException;
            }
        }
开发者ID:MichaelaIvanova,项目名称:Telerik-Software-Academy,代码行数:35,代码来源:ActionInvoker.cs

示例5: InvokingConstructorWithHomeControllerShouldReturnDefaultActionAndParameter

        public void InvokingConstructorWithHomeControllerShouldReturnDefaultActionAndParameter()
        {
            var actionDescriptor = new ActionDescriptor("/Home");

            Assert.AreEqual("Index", actionDescriptor.ActionName);
            Assert.AreEqual(string.Empty, actionDescriptor.Parameter);
        }
开发者ID:MichaelaIvanova,项目名称:Telerik-Software-Academy,代码行数:7,代码来源:ActionDescriptorConstructorTests.cs

示例6: InvokingConstructorWithNormalUriShouldReturnProperlyControllerActionAndParameter

        public void InvokingConstructorWithNormalUriShouldReturnProperlyControllerActionAndParameter()
        {
            var actionDescriptor = new ActionDescriptor("/Api/ResponseMessage/someParam123");

            Assert.AreEqual("Api", actionDescriptor.ControllerName);
            Assert.AreEqual("ResponseMessage", actionDescriptor.ActionName);
            Assert.AreEqual("someParam123", actionDescriptor.Parameter);
        }
开发者ID:MichaelaIvanova,项目名称:Telerik-Software-Academy,代码行数:8,代码来源:ActionDescriptorConstructorTests.cs

示例7: GetFilters

        protected override FilterInfo GetFilters(ControllerContext controllerContext, ActionDescriptor actionDescriptor)
        {
            var rubyType = ((RubyController) controllerContext.Controller).RubyType;
            var controllerFilters = (Hash) RubyEngine.CallMethod(rubyType, "action_filters");

            var info = controllerFilters.ToFilterInfo("controller").MergedWith(actionDescriptor.GetFilters());
            return info;
        }
开发者ID:jschementi,项目名称:ironrubymvc,代码行数:8,代码来源:RubyControllerActionInvoker.cs

示例8: ActionContext

        protected ActionContext(ControllerContext context, ActionDescriptor action)
        {
			Precondition.Require(context, () => Error.ArgumentNull("context"));
            Precondition.Require(action, () => Error.ArgumentNull("action"));

            _action = action;
			_context = context;
        }
开发者ID:radischevo,项目名称:Radischevo.Wahha,代码行数:8,代码来源:ActionContext.cs

示例9: GetFilters

		public IEnumerable<Filter> GetFilters(ControllerContext context, ActionDescriptor action)
		{
			Precondition.Require(context, () => Error.ArgumentNull("context"));
			Precondition.Require(action, () => Error.ArgumentNull("action"));

			if (context.Controller != null)
				yield return new Filter(context.Controller, FilterScope.First, Int32.MinValue);
		}
开发者ID:radischevo,项目名称:Radischevo.Wahha,代码行数:8,代码来源:ControllerFilterProvider.cs

示例10: ReflectedParameterDescriptor

        public ReflectedParameterDescriptor(ParameterInfo parameter, ActionDescriptor action)
            : base()
        {
            Precondition.Require(parameter, () => Error.ArgumentNull("parameter"));
            Precondition.Require(action, () => Error.ArgumentNull("action"));

            _parameter = parameter;
            _action = action;
            _binding = new ReflectedParameterBinding(parameter);
        }
开发者ID:radischevo,项目名称:Radischevo.Wahha,代码行数:10,代码来源:ReflectedParameterDescriptor.cs

示例11: GetActionAttributes

    protected override IEnumerable<FilterAttribute> GetActionAttributes(ControllerContext controllerContext, ActionDescriptor actionDescriptor)
    {
        var attributes = base.GetActionAttributes(controllerContext, actionDescriptor);
        foreach (var attribute in attributes)
        {
            _container.BuildUp(attribute.GetType(), attribute);
        }

        return attributes;
    }
开发者ID:rex-dennis,项目名称:Bonobo-Git-Server,代码行数:10,代码来源:UnityFilterAttributeFilterProvider.cs

示例12: AuthenticationContext

        public AuthenticationContext(ControllerContext controllerContext, ActionDescriptor actionDescriptor)
            : base(controllerContext)
        {
            if (actionDescriptor == null)
            {
                throw new ArgumentNullException("actionDescriptor");
            }

            _actionDescriptor = actionDescriptor;
        }
开发者ID:brianly,项目名称:aspnetwebstack,代码行数:10,代码来源:AuthenticationContext.cs

示例13: GetControllerAttributes

    protected override System.Collections.Generic.IEnumerable<FilterAttribute> GetControllerAttributes(ControllerContext controllerContext, ActionDescriptor actionDescriptor)
    {
        var attributes = base.GetControllerAttributes(controllerContext, actionDescriptor);

        foreach (var attribute in attributes)
        {
            _container.BuildUp(attribute);
        }
        return attributes;
    }
开发者ID:atosorigin,项目名称:AtosMvcStarterKit,代码行数:10,代码来源:StructureMapFilterAttributeFilterProvider.cs

示例14: OnBeforeAction

        public void OnBeforeAction(ActionDescriptor actionDescriptor, HttpContext httpContext, RouteData routeData)
        {
            string name = this.GetNameFromRouteContext(routeData);
            var telemetry = httpContext.RequestServices.GetService<RequestTelemetry>();

            if (!string.IsNullOrEmpty(name) && telemetry != null && telemetry is RequestTelemetry)
            {
                name = httpContext.Request.Method + " " + name;
                ((RequestTelemetry)telemetry).Name = name;
            }
        }
开发者ID:jango2015,项目名称:ApplicationInsights-aspnet5,代码行数:11,代码来源:OperationNameTelemetryInitializer.cs

示例15: Bind

		/// <summary>
		/// 	Executes binding action to context
		/// </summary>
		/// <param name="action"> </param>
		/// <param name="context"> </param>
		public void Bind(ActionDescriptor action, IMvcContext context) {
			lock (this) {
				if (null == _binders) {
					Setup(action.ActionType);
				}
				if (_binders != null) {
					foreach (var binder in _binders) {
						binder.Bind(action.Action, context);
					}
				}
			}
		}
开发者ID:Qorpent,项目名称:qorpent.sys,代码行数:17,代码来源:DefaultActionBinder.cs


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