Created
December 20, 2018 22:04
-
-
Save tonysneed/64ef5a2fbf49faa502c18e6d581b9817 to your computer and use it in GitHub Desktop.
ConfigurationService
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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