using System.Reflection; using DCGEngine.Database.Configuration; using Microsoft.EntityFrameworkCore; using SVSim.Database; using SVSim.Database.Models; using SVSim.Database.Repositories.Card; using SVSim.Database.Repositories.Globals; using SVSim.Database.Repositories.Viewer; using SVSim.EmulatedEntrypoint.Middlewares; using SVSim.EmulatedEntrypoint.Security.SteamSessionAuthentication; using SVSim.EmulatedEntrypoint.Services; namespace SVSim.EmulatedEntrypoint; public class Program { public static void Main(string[] args) { var builder = WebApplication.CreateBuilder(args); // Add services to the container. builder.Services.AddControllers(); // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle builder.Services.AddEndpointsApiExplorer(); builder.Services.AddSwaggerGen(); builder.Services.AddHttpLogging(opt => { }); #region Database Services builder.Services.AddDbContext(opt => { opt.UseNpgsql(builder.Configuration.GetConnectionString("ApplicationDb")); }); builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); #endregion builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.Configure(opt => { opt.DbSetSearchAssemblies = new List { Assembly.GetAssembly(typeof(SVSimDbContext)) }; }); builder.Services.AddSingleton(); builder.Services.AddSingleton(); builder.Services.AddAuthentication() .AddScheme( SteamAuthenticationConstants.SchemeName, opt => { }); var app = builder.Build(); // Update database using (var scope = app.Services.CreateScope()) { var dbContext = scope.ServiceProvider.GetRequiredService(); dbContext.UpdateDatabase(); } app.UseHttpLogging(); // Configure the HTTP request pipeline. if (app.Environment.IsDevelopment()) { app.UseSwagger(); app.UseSwaggerUI(); } //app.UseHttpsRedirection(); app.UseMiddleware(); app.UseMiddleware(); app.UseAuthentication(); app.UseAuthorization(); app.MapControllers(); app.Run(); } }