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