private IDynamicSettingGroup GetGroup(string key, bool create) { if (string.IsNullOrEmpty(key)) { throw new ArgumentException("Key must be a string with one or more characters.", "key"); } if (key[0] == '{' || key[key.Length - 1] == '}') { throw new ArgumentException("Key must not start with '{' and must not end with '}'.", "key"); } IDynamicSettingGroup group; if (!this._groups.TryGetValue(key, out group)) { if (create) { group = new DynamicSettingGroup(key, this); this._groups[key] = group; } else { group = null; } } return(group); }
/// <summary> /// Initialize new <see cref="Setting{T}"/> instance. /// </summary> /// <param name="group">Group for which this setting belongs to.</param> /// <param name="key">Unique key used to identify this setting.</param> /// <param name="defaultValue">Default value of setting which can be restored.</param> /// <param name="filter">Optional delegate which can be used to filter values /// on assignment if specified. It is important to note that default values /// are also filtered on assignment.</param> internal Setting(DynamicSettingGroup group, string key, T defaultValue, FilterValue <T> filter) { this._group = group; this.Key = key; this.DefaultValue = defaultValue; this._filter = filter; }