Ejemplo n.º 1
0
 internal DefaultActionHandler(
     IActionInvokerFactory actionInvokerFactory,
     IActionContextAccessor actionContextAccessor,
     ActionSelectionResult selectionResult,
     ActionDescriptorMatch match)
 {
     this.actionContextAccessor = actionContextAccessor;
     this.actionInvokerFactory  = actionInvokerFactory;
     this.selectionResult       = selectionResult;
     this.match = match;
 }
Ejemplo n.º 2
0
        static string ExpandActionSignature(ActionDescriptorMatch match)
        {
            Contract.Requires(match != null);
            Contract.Ensures(!IsNullOrEmpty(Contract.Result <string>()));

            if (!(match.Action is ControllerActionDescriptor action))
            {
                return(match.Action.DisplayName);
            }

            var signature      = new StringBuilder();
            var controllerType = action.ControllerTypeInfo;

            signature.Append(controllerType.GetTypeDisplayName());
            signature.Append('.');
            signature.Append(action.MethodInfo.Name);
            signature.Append('(');

            using (var parameter = action.Parameters.GetEnumerator())
            {
                if (parameter.MoveNext())
                {
                    var parameterType = parameter.Current.ParameterType;

                    signature.Append(parameterType.GetTypeDisplayName(false));

                    while (parameter.MoveNext())
                    {
                        parameterType = parameter.Current.ParameterType;
                        signature.Append(", ");
                        signature.Append(parameterType.GetTypeDisplayName(false));
                    }
                }
            }

            signature.Append(") (");
            signature.Append(controllerType.Assembly.GetName().Name);
            signature.Append(')');

            return(signature.ToString());
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Occurs when a single action is matched to the route policy.
        /// </summary>
        /// <param name="context">The current <see cref="RouteContext">route context</see>.</param>
        /// <param name="selectionResult">The current <see cref="ActionSelectionResult">action selection result</see>.</param>
        /// <param name="match">The <see cref="ActionDescriptorMatch">matched</see> action.</param>
        protected virtual void OnSingleMatch(RouteContext context, ActionSelectionResult selectionResult, ActionDescriptorMatch match)
        {
            Arg.NotNull(context, nameof(context));
            Arg.NotNull(selectionResult, nameof(selectionResult));
            Arg.NotNull(match, nameof(match));

            var handler    = new DefaultActionHandler(ActionInvokerFactory, ActionContextAccessor, selectionResult, match);
            var candidates = selectionResult.CandidateActions.SelectMany(kvp => kvp.Value);

            match.Action.AggregateAllVersions(candidates);
            context.RouteData = match.RouteData;
            context.Handler   = handler.Invoke;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Occurs when a single action is matched to the route policy.
        /// </summary>
        /// <param name="context">The current <see cref="RouteContext">route context</see>.</param>
        /// <param name="selectionResult">The current <see cref="ActionSelectionResult">action selection result</see>.</param>
        /// <param name="match">The <see cref="ActionDescriptorMatch">matched</see> action.</param>
        protected virtual void OnSingleMatch(RouteContext context, ActionSelectionResult selectionResult, ActionDescriptorMatch match)
        {
            Arg.NotNull(context, nameof(context));
            Arg.NotNull(selectionResult, nameof(selectionResult));
            Arg.NotNull(match, nameof(match));

            var handler = new DefaultActionHandler(ActionInvokerFactory, ActionContextAccessor, selectionResult, match);

            context.RouteData = match.RouteData;
            context.Handler   = handler.Invoke;
        }