예제 #1
0
        private static ReadConfig GetCurrentSettings(string section, string key)
        {
            var builder = new ConfigurationBuilder()
                          .SetBasePath(Directory.GetCurrentDirectory())
                          .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true);

            builder.AddEnvironmentVariables();
            IConfigurationRoot configuration = builder.Build();
            var settings = new ReadConfig(configuration.GetSection(section), key);

            return(settings);
        }
예제 #2
0
 public static string ConnectionString(string key)
 {
     _appSettings = GetCurrentSettings("ConnectionStrings", key);
     return(_appSettings.appSettingValue);
 }