"open config file without dependency injection" Code Answer's
You're definitely familiar with the best coding language Whatever that developers use to develop their projects and they get all their queries like "open config file without dependency injection" answered properly. Developers are finding an appropriate answer about open config file without dependency injection related to the Whatever coding language. By visiting this online portal developers get answers concerning Whatever codes question like open config file without dependency injection. Enter your desired code related query in the search bar and get every piece of information about Whatever code related question on open config file without dependency injection.
open config file without dependency injection
public class AppSettings
{
private static AppSettings _appSettings;
public string AppConnection { get; set; }
public AppSettings(IConfiguration config)
{
this.AppConnection = config.GetValue<string>("AppConnection");
// Now set Current
_appSettings = this;
}
public static AppSettings Current
{
get
{
if(_appSettings == null)
{
_appSettings = GetCurrentSettings();
}
return _appSettings;
}
}
public static AppSettings GetCurrentSettings()
{
var builder = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
.AddEnvironmentVariables();
IConfigurationRoot configuration = builder.Build();
var settings = new AppSettings(configuration.GetSection("AppSettings"));
return settings;
}
}
Source: stackoverflow.com
All those coders who are working on the Whatever based application and are stuck on open config file without dependency injection can get a collection of related answers to their query. Programmers need to enter their query on open config file without dependency injection related to Whatever code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about open config file without dependency injection for the programmers working on Whatever code while coding their module. Coders are also allowed to rectify already present answers of open config file without dependency injection while working on the Whatever language code. Developers can add up suggestions if they deem fit any other answer relating to "open config file without dependency injection". Visit this developer's friendly online web community, CodeProZone, and get your queries like open config file without dependency injection resolved professionally and stay updated to the latest Whatever updates.