コード例 #1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app,
                              IHostingEnvironment env,
                              ILoggerFactory loggerFactory,
                              IApplicationLifetime lifetime,
                              ILocalMemoryRepository ilmr,
                                                         //IRedisCacheRepository iRcr,
                              IMemoryCache imemoryCache) //
        {
            ILmRepo      = ilmr;
            ImemoryCache = imemoryCache;
            //app.UseInMemoryMiddleware();
            //ilmr.GetItems(1);
            //lifetime.ApplicationStarted.Register(OnApplicationStarted);
            //lifetime.ApplicationStarted.Register(() => iRcr.GetItems());

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            loggerFactory.AddLog4Net();
            app.UseCors(builder =>
                        builder.WithOrigins("*")
                        .AllowAnyHeader()
                        .AllowAnyMethod());
            app.UseMvc();
            //app.UseExceptionHandler("/error");
            // Enable middleware to serve generated Swagger as a JSON endpoint.
            app.UseSwagger();
            app.UseAuthentication();
            // Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.),
            // specifying the Swagger JSON endpoint.
            app.UseSwaggerUI(c =>
            {
                c.DocumentTitle = "Sample App";
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "V1");
            });
        }
コード例 #2
0
 public InMemoryMiddleware(RequestDelegate next, ILocalMemoryRepository iLocMemRepo, IMemoryCache iMemoryCache) //
 {
     _next         = next;
     _iLocMemRepo  = iLocMemRepo;
     _iMemoryCache = iMemoryCache;
 }