Skip to content
Jean-Philippe Bruyère edited this page Oct 26, 2021 · 3 revisions

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:

 //storing
 Configuration.Global.Set ("Option1", 42);
 //loading
 int op1 = Configuration.Global.Get<int> ("Option1");

.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'

namespace: Crow

Inheritance Hierarchy

  • Configuration

Syntax

public class Configuration

Constructors

prototype description
Configuration (string path, Stream defaultConf=null) __
Configuration (Stream defaultConf=null) Create readonly configuration

Properties

name description
AppConfigPath __
Global __
Names __

Methods

prototype description
T Get< T >(string key) retrive the value of the configuration key given in parameter
T Get< T >(string key, T defaultValue) retrive the value of the configuration key given in parameter
void Save() __
void Set< T >(string key, T value) store the value of the configuration key given in parameter
bool TryGet< T >(string key, out T result) __

Events

name description
Clone this wiki locally