示例#1
0
        public async Task Invoke(UpdateContext ctx, Func <Task> next)
        {
            SetGlobalSearchBag(ctx);

            var routingCtx = new RoutingContext(ctx);
            await _mainRouter.RouteAsync(routingCtx);

            //Handler found.
            var actDesc = routingCtx.ActionDescriptor;

            if (actDesc != null)
            {
                var ctxLogger = ctx.Logger();
                if (ctxLogger.IsEnabled(LogLevel.Trace))
                {
                    ctxLogger
                    .LogTrace(
                        $"Mvc start processing context with '{actDesc.RouteInfo.Template ?? actDesc.RouteInfo.Name}'."
                        );
                }

                var actionContext = _contextPreparer.CreateContext(ctx, actDesc);
                await actDesc.Handler.Invoke(actionContext);

                await InvokeActionByName(actionContext, 1);
            }
            await next();
        }
示例#2
0
        /// <summary>
        /// If mvc has method with bigger priority - return true.
        /// <para></para>
        /// Lower number mean bigger priority.
        /// </summary>
        public async Task <bool> CheckMvcHasPriorityHandler(UpdateContext updateContext, int yourMethodOrder)
        {
            var routingContext = new RoutingContext(updateContext);
            await _mainRouter.RouteAsync(routingContext);

            if (routingContext.ActionDescriptor != null)
            {
                return(routingContext.ActionDescriptor.RouteInfo.Order <= yourMethodOrder);
            }
            return(false);
        }