I want to implement a class whose instance is global but whose property is to be initialized only once during the run time.
Also the initialization is to be done as an assignment from a result of function during execution.
Basically I want to do something like this
public class Configuration
{
public string param1 { get ; set; }
public int param2 { get; set; }
}
public static class AppConfig
{
public static readonly configuration;
}
public class Initialize
{
public void InitConfig()
{
AppConfig.configuration = GetParamsFromDB();
}
}
But I am unable to figure out how to implement it. Please ignore the above incorrect representation. It is just to present what is required.
EDIT
Also there is a need of seperate class Initialize because classes Configuration and AppConfig are in dll BO. GetParamsFromDB() is in DAL. DAL references BO hence BO cannot refere DAL hence GetParamsFromDB() cannot be used within AppConfig class