Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

StartupConfiguration.cs 879B

12345678910111213141516171819202122232425262728
  1. using Microsoft.Extensions.Configuration;
  2. using Microsoft.Extensions.DependencyInjection;
  3. namespace SecureSharing.Business.Infrastructure;
  4. public sealed class StartupConfiguration
  5. {
  6. public static TConfig ConfigureStartupConfig<TConfig>(IServiceCollection services, IConfiguration configuration)
  7. where TConfig : class, new()
  8. {
  9. if (services is null)
  10. throw new ArgumentNullException(nameof(services));
  11. if (configuration is null)
  12. throw new ArgumentNullException(nameof(configuration));
  13. //create instance of config
  14. var config = new TConfig();
  15. var classType = typeof(TConfig);
  16. //bind it to the appropriate section of configuration
  17. configuration.Bind(classType.Name, config);
  18. //and register it as a service
  19. services.AddSingleton(config);
  20. return config;
  21. }
  22. }