Made the service provider available by the program class

This commit is contained in:
Thorsten Sommer 2025-02-16 15:20:47 +01:00
parent d24f59a837
commit 3b80462536
Signed by: tsommer
GPG Key ID: 371BBA77A02C0108

View File

@ -21,6 +21,7 @@ internal sealed class Program
public static RustService RUST_SERVICE = null!; public static RustService RUST_SERVICE = null!;
public static Encryption ENCRYPTION = null!; public static Encryption ENCRYPTION = null!;
public static string API_TOKEN = null!; public static string API_TOKEN = null!;
public static IServiceProvider SERVICE_PROVIDER = null!;
public static async Task Main(string[] args) public static async Task Main(string[] args)
{ {
@ -148,6 +149,10 @@ internal sealed class Program
var programLogger = app.Services.GetRequiredService<ILogger<Program>>(); var programLogger = app.Services.GetRequiredService<ILogger<Program>>();
programLogger.LogInformation("Starting the AI Studio server."); programLogger.LogInformation("Starting the AI Studio server.");
// Store the service provider (DI). We need it later for some classes,
// which are not part of the request pipeline:
SERVICE_PROVIDER = app.Services;
// Initialize the encryption service: // Initialize the encryption service:
programLogger.LogInformation("Initializing the encryption service."); programLogger.LogInformation("Initializing the encryption service.");
var encryptionLogger = app.Services.GetRequiredService<ILogger<Encryption>>(); var encryptionLogger = app.Services.GetRequiredService<ILogger<Encryption>>();