using dotnetCHARTING.NET10.Services;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
namespace dotnetCHARTING.NET10
{
    public class Startup
    {
        public Startup(IConfiguration configuration, IWebHostEnvironment hostingEnvironment)
        {
            DNC.Configuration = Configuration = configuration;
            DNC.HostingEnvironment = HostingEnvironment = hostingEnvironment;
        }
        //public Startup(IConfiguration configuration, IWebHostEnvironment hostingEnvironment, IHttpContextAccessor httpCtxAccessor)
        //{
        //    DNC.Configuration = Configuration = configuration;
        //    DNC.HostingEnvironment = HostingEnvironment = hostingEnvironment;
        //    DNC.HttpContextAccessor = httpCtxAccessor;        
        //}
        public IConfiguration Configuration { get; }
        public IWebHostEnvironment HostingEnvironment { get; }
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddRazorPages();
            services.AddHttpContextAccessor();
            services.AddSingleton<MyMemoryCache>();
        }
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Error");
            }
            app.UseStaticFiles();
            app.UseRouting();
            app.UseAuthorization();
            app.UseEndpoints(endpoints =>
            {
                endpoints.MapRazorPages();
            });
        }
    }
}
