Ejemplo n.º 1
0
 public async Task Invoke([NotNull] HttpContext context)
 {
     if (_options.Predicate != null)
     {
         if (_options.Predicate(context))
         {
             await _options.Branch(context);
         }
         else
         {
             await _next(context);
         }
     }
     else
     {
         if (await _options.PredicateAsync(context))
         {
             await _options.Branch(context);
         }
         else
         {
             await _next(context);
         }
     }
 }
        /// <summary>
        /// Executes the middleware.
        /// </summary>
        /// <param name="context">The <see cref="HttpContext"/> for the current request.</param>
        /// <returns>A task that represents the execution of this middleware.</returns>
        public async Task Invoke(HttpContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            if (_options.Predicate(context))
            {
                await _options.Branch(context);
            }
            else
            {
                await _next(context);
            }
        }