I am trying to learn ASP.NET 5. I am using it on Mac OS X. At this time, I have a config.json file that looks like the following:
config.json
You can simply access the value of config property Environment
by using Configuration
class like this anywhere in your application.
var environment = Configuration["AppSettings:Environment"];
But if you want it to access through a property of class you can do this
public class AppSettings
{
public string Environment
{
get
{
return new Configuration().Get("AppSettings:Environment").ToString();
}
set;
}
}
Note I haven't set the value of Environment
in setter because this value will be in config.json
so there is no need to set this value in setter.
For more details have a look at this article.