private static void ConfigureServices(IServiceCollection _serviceCollection) { // Add logging ConfigureLogger(_serviceCollection); _serviceCollection.AddTransient <IArgService, ArgService>(); // Build configuration var configuration = new ConfigurationBuilder() .SetBasePath(baseDirectory) .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) .Build(); // Add access to generic IConfigurationRoot _serviceCollection.AddSingleton(configuration); ConnectAPI configAPI = new ConnectAPI(); configuration.GetSection("connectapi").Bind(configAPI); _serviceCollection.AddSingleton(configAPI); // Add app serviceCollection.AddTransient <App>(); }
public App(ILogger <App> logger, ConnectAPI _configAPI) { _logger = logger; apiConfig = _configAPI; }