diff options
| author | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2018-02-03 06:38:35 +0100 |
|---|---|---|
| committer | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2018-02-03 06:38:35 +0100 |
| commit | c686be8c88d33ff397e24c2b7d6e2d2240b2f64b (patch) | |
| tree | 7ab4e3c3f8bfb058f91d6859098504538fffaf10 /src/Configuration.cs | |
| parent | 11e428d0a8933bca79f0b674d5b10590be60dbbd (diff) | |
:book: use own compiled opentk and remove nuget config
Diffstat (limited to 'src/Configuration.cs')
| -rw-r--r-- | src/Configuration.cs | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/src/Configuration.cs b/src/Configuration.cs index 8f89dbfc..39c3c9cb 100644 --- a/src/Configuration.cs +++ b/src/Configuration.cs @@ -32,6 +32,9 @@ using System.Threading; namespace Crow { + /// <summary> + /// single element of configuration + /// </summary> public class ConfigItem { Type type; internal object curVal; @@ -59,8 +62,26 @@ namespace Crow } } /// <summary> - /// Application wide Configuration utility + /// Application wide Configuration store utility + /// + /// configuration files are automatically stored in **_user/.config/appname/app.config_** on close and every minutes + /// if some items have changed. + /// New items are automaticaly added on first use. Configuration class expose one templated Get and one Templated Set, so + /// creating, storing and retrieving config items is simple as: + /// + /// ```csharp\n + /// //storing\n + /// Configuration.Set ("Option1", 42);\n + /// //loading\n + /// int op1 = Configuration.Get<int> ("Option1");\n + /// ```\n /// </summary> + /// + /// **.config** file are simple text files with per line, a key/value pair of the form `option=value`. Keys have to be unique + /// in the application scope. + /// + /// When running the application for the first time, some default options may be necessary. Their can be defined + /// in a special embedded resource text file with the key '**appname.default.config**' public static class Configuration { volatile static bool isDirty = false; @@ -118,10 +139,19 @@ namespace Crow Thread.Sleep (1000); } } + /// <summary> + /// retrive the value of the configuration key given in parameter + /// </summary> + /// <param name="key">option name</param> public static T Get<T>(string key) { return !items.ContainsKey (key) ? default(T) : items [key].GetValue<T> (); } + /// <summary> + /// store the value of the configuration key given in parameter + /// </summary> + /// <param name="key">option name</param> + /// <param name="value">value for that option</param> public static void Set<T>(string key, T value) { if (!items.ContainsKey (key)) { |