| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- using DataLayer;
- using DataLayer.Interfaces;
- using Deathwatch.Data;
- using Services;
- using Services.Interfaces;
- using Microsoft.EntityFrameworkCore;
- using Infrastructure;
- using Microsoft.Extensions.DependencyInjection;
- var builder = WebApplication.CreateBuilder(args);
- // Add services to the container.
- builder.Services.AddRazorPages();
- builder.Services.AddServerSideBlazor();
- builder.Services.AddSingleton<WeatherForecastService>();
- builder.Services.AddDbContext<DeathwatchDbContext>(options =>
- options.UseInMemoryDatabase("InMemoryDb"));
- builder.Services.AddTransient(typeof(IAbstractRepository<>), typeof(AbstractRepository<>));
- builder.Services.AddTransient<IPlayerService, PlayerService>();
- builder.Services.AddTransient<IPlayerRepository, PlayerRepository>();
- builder.Services.AddHttpClient();
- //builder.Services.AddSqlite<DeathwatchDbContext>("Data Source=deathwatch.db");
- var currentDirectory = Directory.GetCurrentDirectory();
- string folderPath = $"{currentDirectory}/XML/";
- string outputJsonFilePath = $"{currentDirectory}/outputfile.json";
- var app = builder.Build();
- var scopeFactory = app.Services.GetRequiredService<IServiceScopeFactory>();
- using (var scope = scopeFactory.CreateScope())
- {
- var db = scope.ServiceProvider.GetRequiredService<DeathwatchDbContext>();
- if (db.Database.EnsureCreated())
- {
- DbContextInitializer.Initialize(db);
- }
- }
- // Configure the HTTP request pipeline.
- if (!app.Environment.IsDevelopment())
- {
- app.UseExceptionHandler("/Error");
- // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
- app.UseHsts();
- }
- app.UseHttpsRedirection();
- app.UseStaticFiles();
- app.UseRouting();
- app.MapBlazorHub();
- app.MapFallbackToPage("/_Host");
- app.Run();
|