Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
ConfigurationService
public class ConfigurationService : IConfigurationService
{
public IEnvironmentService EnvService { get; }
public string CurrentDirectory { get; set; }
public ConfigurationService(IEnvironmentService envService)
{
EnvService = envService;
}
public IConfiguration GetConfiguration()
{
CurrentDirectory = CurrentDirectory ?? Directory.GetCurrentDirectory();
return new ConfigurationBuilder()
.SetBasePath(CurrentDirectory)
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
.AddJsonFile($"appsettings.{EnvService.EnvironmentName}.json", optional: true)
.AddEnvironmentVariables()
.Build();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.