/// <summary> /// Constructs a new ambient settings set with the specified values. /// </summary> /// <param name="name">The name of the set.</param> public BasicAmbientSettingsSet(string name) { _name = name; _rawValues = new ConcurrentDictionary <string, string>(); _typedValues = new ConcurrentDictionary <string, object>(); _weakSettingRegistered = new LazyUnsubscribeWeakEventListenerProxy <BasicAmbientSettingsSet, object?, IAmbientSettingInfo>( this, NewSettingRegistered, wvc => SettingsRegistry.DefaultRegistry.SettingRegistered -= wvc.WeakEventHandler); SettingsRegistry.DefaultRegistry.SettingRegistered += _weakSettingRegistered.WeakEventHandler; }
/// <summary> /// Constructs a new ambient settings set with the specified values. /// </summary> /// <param name="name">The name of the set.</param> /// <param name="values">A set of name-value pairs to use for the initial values for the set.</param> public BasicAmbientSettingsSet(string name, IDictionary <string, string> values) { _name = name; _rawValues = new ConcurrentDictionary <string, string>(values); _typedValues = new ConcurrentDictionary <string, object>(); if (values != null) { foreach (string key in values.Keys) { IAmbientSettingInfo?ps = SettingsRegistry.DefaultRegistry.TryGetSetting(key); _typedValues[key] = (ps != null) ? ps.Convert(this, values[key]) : values[key]; } } _weakSettingRegistered = new LazyUnsubscribeWeakEventListenerProxy <BasicAmbientSettingsSet, object?, IAmbientSettingInfo>( this, NewSettingRegistered, wvc => SettingsRegistry.DefaultRegistry.SettingRegistered -= wvc.WeakEventHandler); SettingsRegistry.DefaultRegistry.SettingRegistered += _weakSettingRegistered.WeakEventHandler; }