I am writing a console application and have a class called ApplicationConfiguration
that contains methods to check some of the settings and also return values from my app.config file. For instance the following method in the ApplicationConfiguration
class returns the location of log file from my app.config
file:
public string ProjectLog
{
get
{
_projectLog = ConfigurationManager.AppSettings["ProjectLog"].ToString();
return _projectLog;
}
}
I have a FileLogger
class and DBConnection
class that also would need values returned from methods in ApplicationConfiguration
. My question is since the values in the app.config file are used in many of my other classes do I have to instantiate ApplicationConfiguration
in every class that may need my config values like so?
public class FileLogger
{
ApplicationConfiguration appConfig = new ApplicationConfiguration();
}
public class DBConnection
{
ApplicationConfiguration appConfig = new ApplicationConfiguration();
}