19 using System.Collections.Generic;
24 namespace Deveel.Data.Configuration {
27 private readonly Dictionary<string, object>
values;
35 values =
new Dictionary<string, object>();
45 : this(parent == null) {
54 : this(null, source) {
62 : this(parent, null) {
73 var returnKeys =
new Dictionary<string, string>();
75 var configKeys = Parent.GetKeys(level);
76 foreach (var pair
in configKeys) {
77 returnKeys[pair] = pair;
81 foreach (var configKey
in values.Keys) {
82 returnKeys[configKey] = configKey;
85 return returnKeys.Values.AsEnumerable();
90 return keys.Select(key =>
new KeyValuePair<string, object>(key, GetValue(key))).GetEnumerator();
93 IEnumerator IEnumerable.GetEnumerator() {
94 return GetEnumerator();
99 public void SetValue(
string key,
object value) {
100 if (String.IsNullOrEmpty(key))
101 throw new ArgumentNullException(
"key");
112 if (String.IsNullOrEmpty(key))
113 throw new ArgumentNullException(
"key");
116 if (values.TryGetValue(key, out value))
119 if (!isRoot && Parent != null &&
120 ((value = Parent.GetValue(key)) != null))
IEnumerable< string > GetKeys(ConfigurationLevel level)
Enumerates the keys that can be obtained by the object, at the given ConfigurationLevel.
readonly Dictionary< string, object > values
A source for stored configurations or destination to configurations to store.
Configuration(IConfiguration parent)
ConfigurationLevel
Defines the level of configuration settings to save or read
void SetValue(string key, object value)
Sets a given value for a key defined by this object.
IEnumerator< KeyValuePair< string, object > > GetEnumerator()
Configuration(IConfiguration parent, IConfigSource source)
Constructs the Configuration from the given parent.
Defines the contract for the configuration node of a component within the system or of the system its...
object GetValue(string key)
Gets a configuration setting for the given key.
Configuration(IConfigSource source)
Configuration(bool isRoot)
Constructs the Configuration.