示例#1
0
        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>();
        }
示例#2
0
 public App(ILogger <App> logger, ConnectAPI _configAPI)
 {
     _logger   = logger;
     apiConfig = _configAPI;
 }