Beispiel #1
0
        /// <summary>
        /// 拦截异步有返回值方法。
        /// </summary>
        /// <typeparam name="T">返回值类型。</typeparam>
        /// <param name="context">上下文。</param>
        /// <returns></returns>
        public static Task <T> InterceptAsync <T>(NestedInterceptContext context)
        {
            var intercept = new InterceptAsync <T>();

            foreach (InterceptAttribute attribute in GetInterceptAttributes(context.DestinationProxyMethod))
            {
                intercept = new MiddlewareInterceptAsync <T>(attribute, intercept);
            }

            return(intercept.RunAsync(context));
        }
        /// <summary>
        /// /构造函数。
        /// </summary>
        /// <param name="middleware">拦截器。</param>
        /// <param name="intercept">拦截器。</param>
        public MiddlewareInterceptAsync(InterceptAttribute middleware, InterceptAsync intercept)
        {
            if (middleware is null)
            {
                throw new ArgumentNullException(nameof(middleware));
            }

            if (intercept is null)
            {
                throw new ArgumentNullException(nameof(intercept));
            }

            this.middleware = middleware;
            this.intercept  = intercept;
        }
Beispiel #3
0
        /// <summary>
        /// 运行方法(异步有返回值)。
        /// </summary>
        /// <param name="context">上下文。</param>
        /// <param name="intercept">拦截器。</param>

        public abstract Task <T> RunAsync <T>(InterceptContext context, InterceptAsync <T> intercept);
Beispiel #4
0
        /// <summary>
        /// 运行方法(异步无返回值)。
        /// </summary>
        /// <param name="context">上下文。</param>
        /// <param name="intercept">拦截器。</param>

        public abstract Task RunAsync(InterceptContext context, InterceptAsync intercept);
Beispiel #5
0
 /// <inheritdoc />
 public override Task <T> RunAsync <T>(InterceptContext context, InterceptAsync <T> intercept)
 {
     return(intercept.RunAsync(context));
 }