using LANCommander.SDK; using LANCommander.Server.Services.MediaGrabbers; using LANCommander.Server.Services; using Serilog; using Hangfire; using LANCommander.Server.Data; using LANCommander.Server.Services.Factories; using LANCommander.Server.Services.Importers; using LANCommander.Server.Services.Models; namespace LANCommander.Server; public static class ServiceExtensions { public static void AddLANCommanderServices(this WebApplicationBuilder builder, Settings settings) { Log.Debug("Registering services"); builder.Services.AddSingleton(new Client("", "")); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddTransient(); builder.Services.AddScoped(typeof(ImportService<>)); // Register importers builder.Services.AddScoped, GameImporter>(); builder.Services.AddScoped, ServerImporter>(); builder.Services.AddScoped, RedistributableImporter>(); builder.Services.AddSingleton(); builder.Services.AddSingleton(); builder.Services.AddAutoMapper(typeof(LANCommanderMappingProfile)); builder.Services.AddFusionCache(); builder.Services.AddAntDesign(); builder.Services.AddHttpClient(); builder.Services.AddHttpContextAccessor(); if (settings.Beacon.Enabled) { Log.Debug("The beacons have been lit! LANCommander calls for players!"); builder.Services.AddHostedService(); } } public static void AddAsService(this WebApplicationBuilder builder) { builder.Services.AddWindowsService(options => { options.ServiceName = "LANCommander Server"; }); builder.Services.AddSystemd(); } public static void AddHangfire(this WebApplicationBuilder builder) { builder.Services.AddHangfire(static (sp, configuration) => { var logger = sp.GetRequiredService>(); logger.LogDebug("Initializing Hangfire"); configuration .SetDataCompatibilityLevel(CompatibilityLevel.Version_170) .UseSimpleAssemblyNameTypeSerializer() .UseRecommendedSerializerSettings() .UseInMemoryStorage(); }); builder.Services.AddHangfireServer(); } public static void AddDatabase(this WebApplicationBuilder builder) { builder.Services.AddDbContextFactory(); builder.Services.AddDbContext(); builder.Services.AddDatabaseDeveloperPageExceptionFilter(); } }