public static IApplicationBuilder UsePrimeChecker(this IApplicationBuilder builder,
     PrimeCheckerOptions options)
 {
     if(builder == null)
     {
         throw new ArgumentNullException(nameof(builder));
     }
     var primeService = builder.ApplicationServices.GetService(typeof (PrimeService)) as PrimeService;
     return builder.Use(next => new PrimeCheckerMiddleware(next, options, primeService).Invoke);
 }
        public static IApplicationBuilder UsePrimeChecker(this IApplicationBuilder builder,
                                                          PrimeCheckerOptions options)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }
            var primeService = builder.ApplicationServices.GetService(typeof(PrimeService)) as PrimeService;

            return(builder.Use(next => new PrimeCheckerMiddleware(next, options, primeService).Invoke));
        }
        public PrimeCheckerMiddleware(RequestDelegate next,
                                      PrimeCheckerOptions options,
                                      PrimeService primeService)
        {
            if (next == null)
            {
                throw new ArgumentNullException(nameof(next));
            }
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }
            if (primeService == null)
            {
                throw new ArgumentNullException(nameof(primeService));
            }

            _next         = next;
            _options      = options;
            _primeService = primeService;
        }
Ejemplo n.º 4
0
        public PrimeCheckerMiddleware(RequestDelegate next,
            PrimeCheckerOptions options,
            PrimeService primeService)
        {
            if (next == null)
            {
                throw new ArgumentNullException(nameof(next));
            }
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }
            if (primeService == null)
            {
                throw new ArgumentNullException(nameof(primeService));
            }

            _next = next;
            _options = options;
            _primeService = primeService;
        }