Example #1
0
 public PigpotMiddleware(
     RequestDelegate next,
     ILoggerFactory loggerFactory,
     IOptions <PigpotOptions> options)
 {
     _next    = next;
     _logger  = loggerFactory.CreateLogger <PigpotMiddleware>();
     _options = options.Value;
 }
        public static IServiceCollection AddPigpot(this IServiceCollection services, Action <PigpotOptions> setup = null)
        {
            PigpotOptions options = new PigpotOptions();

            setup?.Invoke(options);

            services.AddSingleton <IRequestHandlerFilter>(x => { return(options.RequestHandlerFilter); });
            services.AddSingleton <ICatalogResolver>(x => { return(options.CatalogResover); });
            services.AddSingleton <IRepositoryFilter>(x => { return(options.RepositoryFilter); });

            services.AddSingleton <IRequestHandler, GetClientApp>();
            services.AddSingleton <IRequestHandler, GetSingle>();
            services.AddSingleton <IRequestHandler, GetAll>();
            services.AddSingleton <IRequestHandler, AddSingle>();
            services.AddSingleton <IRequestHandler, UpdateSingle>();
            services.AddSingleton <IRequestHandler, AddOrUpdateSingle>();
            services.AddSingleton <IRequestHandler, DeleteSingle>();

            return(services);
        }