i documented myself but couldn't found or understood how can i do what i want to achieve.
here is the thing :
- I cannot use registry (not sure i have rights on client computer)
- it need to be generic and transparent (code-side)
i have configuration settings in a project folder, let's says :
- Solution
- project1
- many code folder..
- Settings
- UserLevel
- FirstEnv.settings
- SecondEnv.settings
- ApplicationLevel
- FirstEnv.settings
- SecondEnv.settings
- UserLevel
- project2
- project1
now I have a SettingFactory which (should) instantiate (or a least, assign value) in *.settings to my applicationSettings i want to have something like :
public static void LoadSetting()
{
var env = ConfigurationManager.AppSettings["environnement"];
switch (env)
{
case "env1": ConfigurationManager.OpenExeConfiguration("Setting/AppLevel/firstEnv.settings");
break;
case "env2": ConfigurationManager.OpenExeConfiguration("Setting/AppLevel/secondEnv.settings");
break;
default : ConfigurationManager.OpenExeConfiguration("Setting/AppLevel/secondEnv.settings");
break;
}
}
and a '(key,value)' in app.config
<applicationSettings>
<add name="environnement" value="env1"/>
</applicationSettings>
So in my code, when i need to use settings i can simply refer to
ConfigurationManager.appsettings["targetURI"]
and when i want to switch 'environnement'
ConfigurationManager.appsettings["environnement"] = "env2";
SettingsFactory.LoadSettings();
Any advice on how to do this or any design pattern improvement ?
Moreover, i separate AppLevel settings and Userlevel settings, but it's kinda nothing more than a pair of (key,value). But easier for dev to work with. This way, i can modify environnement with ease by Code ( 2lines) or by editing app.config
Thanks,