Пример #1
0
        /// <summary>
        /// Process an individual request.
        /// </summary>
        /// <param name="environment"></param>
        /// <returns></returns>
        public async Task Invoke(IDictionary <string, object> environment)
        {
            IOwinContext context = new OwinContext(environment);

            if (_options.Predicate != null)
            {
                if (_options.Predicate(context))
                {
                    await _options.Branch(environment);
                }
                else
                {
                    await _next(environment);
                }
            }
            else
            {
                if (await _options.PredicateAsync(context))
                {
                    await _options.Branch(environment);
                }
                else
                {
                    await _next(environment);
                }
            }
        }
Пример #2
0
 /// <summary>
 /// Process an individual request.
 /// </summary>
 /// <param name="context"></param>
 /// <returns></returns>
 public override async Task Invoke(IOwinContext context)
 {
     if (context == null)
     {
         throw new ArgumentNullException("context");
     }
     if (_options.Predicate != null)
     {
         if (_options.Predicate(context))
         {
             await _options.Branch.Invoke(context);
         }
         else
         {
             await Next.Invoke(context);
         }
     }
     else
     {
         if (await _options.PredicateAsync(context))
         {
             await _options.Branch.Invoke(context);
         }
         else
         {
             await Next.Invoke(context);
         }
     }
 }