Refactor: Make Build method private to ensure IServiceProvider is only created via Lazy initialization for thread safety and consistency.

This commit is contained in:
Developer 02 2024-06-27 12:35:37 +02:00
parent f128a719e8
commit 52d350ae48

View File

@ -14,7 +14,7 @@ namespace DigitalData.Core.Client
"Further modifications to the service collection are not allowed. " +
"This is to ensure that the dependency injection container remains in a consistent state.");
public static IServiceProvider Build() => _services.BuildServiceProvider();
private static IServiceProvider Build() => _services.BuildServiceProvider();
public static T Provide<T>() where T : notnull => _lazyProvider.Value.GetRequiredService<T>();
}