The Vici Configuration Framework allows you to map any object or static class to one or more configuration sources. Configuration sources are usually key-value stores (such as the app.config appSettings).
Configuration sources are handled by plugins. The following providers are included by default:
For example, if you have the following class:
public static class Config { public static string DataPath; public static int MaxLoginAttempts }
Using the AppConfig provider, you can have the following app.config:
<appSettings> <add key="DataPath" value="D:\Data" /> <add key="MaxLoginAttempts" value="3" /> </appSettings>
Then you can map your static Config class to the configuration source like this:
ConfigManager configManager = new ConfigManager(); configManager.RegisterProvider(new ConfigurationProviderAppConfig()); configManager.Register<Config>(); configManager.Update();
You can also map object hierarchies:
public static Class Config { class _Paths : IConfigObject { public string Logging; public string Data; } public static _Paths Paths; public int MaxLoginAttempts; }
Your app.config could look like this:
<appSettings> <add key="Paths.Data" value="D:\Data" /> <add key="Paths.Logging" value="D:\Logs" /> <add key="MaxLoginAttempts" value="3" /> </appSettings>
And in your application you can simply access the properties:
string logPath = Config.Paths.Logging; string dataPath = Config.Paths.Data;