public static ConfigurationSettingsGroupSearchCriteria GetCriteria(SettingsGroupDescriptor descriptor) { ConfigurationSettingsGroupSearchCriteria where = new ConfigurationSettingsGroupSearchCriteria(); where.Name.EqualTo(descriptor.Name); where.VersionString.EqualTo(VersionUtils.ToPaddedVersionString(descriptor.Version, false, false)); return where; }
public override void SetPropertyValues(SettingsContext context, SettingsPropertyValueCollection collection) { lock (_syncLock) { // locate dirty values that should be saved var valuesToStore = new Dictionary<string, string>(); foreach (SettingsPropertyValue value in collection) { //If storing the shared values, we store everything, otherwise only store user values. if (value.IsDirty) { valuesToStore[value.Name] = (string) value.SerializedValue; } } if (valuesToStore.Count > 0) { var settingsClass = (Type)context["SettingsClassType"]; var settingsKey = (string)context["SettingsKey"]; var group = new SettingsGroupDescriptor(settingsClass); if (group.HasUserScopedSettings) throw new ConfigurationErrorsException(SR.SystemConfigurationSettingsProviderUserSetting); _store.PutSettingsValues(group, null, settingsKey, valuesToStore); // successfully saved user settings are no longer dirty foreach (var storedValue in valuesToStore) collection[storedValue.Key].IsDirty = false; } } }
public SettingsGroupDescriptor GetPreviousSettingsGroup(SettingsGroupDescriptor @group) { var newGroup = new SettingsGroupDescriptor(@group.Name, new Version(0, 9), @group.Description, @group.AssemblyQualifiedTypeName, @group.HasUserScopedSettings); var matchingSetting = FindSetting(@group); var previousSetting = FindSetting(newGroup); if (matchingSetting == null) { if (previousSetting != null) return newGroup; return null; } if (previousSetting == null) { var newSetting = new Setting { Group = newGroup, Values = new Dictionary<string, string>() }; _settingsList.Add(newSetting); foreach (var key in matchingSetting.Values.Keys) { var val = matchingSetting.Values[key]; newSetting.Values[key] = val + TestString; } } return newGroup; }
private SettingsPropertyValueCollection GetPropertyValues(SettingsContext context, SettingsPropertyCollection properties, bool returnPrevious) { Type settingsClass = (Type)context["SettingsClassType"]; string settingsKey = (string)context["SettingsKey"]; string user = Thread.CurrentPrincipal.Identity.Name; var group = new SettingsGroupDescriptor(settingsClass); if (returnPrevious) group = _store.GetPreviousSettingsGroup(group); else if (AnyUserScoped(properties)) SettingsMigrator.MigrateUserSettings(group); var storedValues = new Dictionary<string, string>(); if (group != null) { foreach (var userDefault in _store.GetSettingsValues(group, null, settingsKey)) storedValues[userDefault.Key] = userDefault.Value; foreach (var userValue in _store.GetSettingsValues(group, user, settingsKey)) storedValues[userValue.Key] = userValue.Value; } return GetSettingsValues(properties, storedValues); }
/// <summary> /// Returns a list of <see cref="SettingsPropertyDescriptor"/> objects describing each property belonging /// to a settings group. /// </summary> public static List<SettingsPropertyDescriptor> ListSettingsProperties(SettingsGroupDescriptor group) { Type settingsClass = Type.GetType(group.AssemblyQualifiedTypeName); return CollectionUtils.Map(SettingsClassMetaDataReader.GetSettingsProperties(settingsClass), (PropertyInfo property) => new SettingsPropertyDescriptor(property)); }
/// <summary> /// Updates this instance from the specified descriptor. /// </summary> /// <param name="descriptor"></param> public virtual void UpdateFromDescriptor(SettingsGroupDescriptor descriptor) { _assemblyQualifiedTypeName = descriptor.AssemblyQualifiedTypeName; _name = descriptor.Name; _versionString = VersionUtils.ToPaddedVersionString(descriptor.Version, false, false); _description = descriptor.Description; _hasUserScopedSettings = descriptor.HasUserScopedSettings; }
/// <summary> /// Stores the settings values (both application and user scoped) for a given settings class. Only the shared profile /// is supported (application settings + default user settings). /// </summary> /// <param name="group">the settings class for which to store the values</param> /// <param name="user">must be null or ""</param> /// <param name="instanceKey">must be null or ""</param> /// <param name="dirtyValues">contains the values to be stored</param> /// <exception cref="NotSupportedException">will be thrown if the user or instance key is specified</exception> public void PutSettingsValues(SettingsGroupDescriptor group, string user, string instanceKey, Dictionary<string, string> dirtyValues) { CheckUser(user); CheckInstanceKey(instanceKey); Type type = Type.GetType(group.AssemblyQualifiedTypeName, true); SystemConfigurationHelper.PutSettingsValues(_configuration, type, dirtyValues); }
private Setting FindSetting(SettingsGroupDescriptor @group) { foreach (var setting in _settingsList) { if (group.Name == setting.Group.Name && group.Version == setting.Group.Version) { return setting; } } return null; }
/// <summary> /// Returns a list of <see cref="SettingsPropertyDescriptor"/> objects describing each property belonging /// to a settings group. /// </summary> /// <remarks> /// The specified group must refer to a locally installed settings class. /// </remarks> public static List<SettingsPropertyDescriptor> ListSettingsProperties(SettingsGroupDescriptor group) { Platform.CheckForNullReference(group, "group"); var settingsClass = Type.GetType(group.AssemblyQualifiedTypeName); if(settingsClass == null) throw new SettingsException(string.Format("{0} is not a locally installed settings group.", group.Name)); return CollectionUtils.Map(SettingsClassMetaDataReader.GetSettingsProperties(settingsClass), (PropertyInfo property) => new SettingsPropertyDescriptor(property)); }
/// <summary> /// Calls <see cref="ApplicationSettingsBase.Reload"/> on all registered /// settings instances that match the specified group. /// </summary> public void Reload(SettingsGroupDescriptor group) { Type settingsClass = Type.GetType(group.AssemblyQualifiedTypeName, false); if (settingsClass != null) { lock (_syncLock) { _registeredSettingsInstances .FindAll(delegate(ApplicationSettingsBase instance) { return instance.GetType().Equals(settingsClass); }) .ForEach(delegate(ApplicationSettingsBase instance) { instance.Reload(); }); } } }
public void SettingsPrior() { const string testVal = "A man, a plan, a canal, panama 2"; const string testValOld = "A man, a plan, a canal, panama 3"; var store = new SystemConfigurationSettingsStore(); var settings = new AppSettings(); var group = new SettingsGroupDescriptor(typeof(AppSettings)); settings.App = testVal; var dic = new Dictionary<string, string>(); dic.Add(AppSettings.PropertyApp, settings.App); store.PutSettingsValues(group, null, null, dic); var oldGroup = new SettingsGroupDescriptor(group.Name, new Version(group.Version.Major -1,group.Version.Minor, group.Version.Build,group.Version.Revision), group.Description, group.AssemblyQualifiedTypeName, group.HasUserScopedSettings); dic[AppSettings.PropertyApp] = testValOld; store.PutSettingsValues(oldGroup, null, null, dic); var resultDic = store.GetSettingsValues(group, null, null); string val; Assert.IsTrue(resultDic.TryGetValue(AppSettings.PropertyApp, out val)); Assert.AreEqual(val, testVal); resultDic = store.GetSettingsValues(oldGroup, null, null); Assert.IsTrue(resultDic.TryGetValue(AppSettings.PropertyApp, out val)); Assert.AreEqual(val, testValOld); var returnedOldGroup = store.GetPreviousSettingsGroup(group); Assert.IsNotNull(returnedOldGroup); Assert.AreEqual(returnedOldGroup.Version.Major, oldGroup.Version.Major); Assert.AreEqual(returnedOldGroup.Version.Minor, oldGroup.Version.Minor); Assert.AreEqual(returnedOldGroup.Description, oldGroup.Description); Assert.AreEqual(returnedOldGroup.Name, oldGroup.Name); Assert.AreEqual(returnedOldGroup.AssemblyQualifiedTypeName, oldGroup.AssemblyQualifiedTypeName); returnedOldGroup = store.GetPreviousSettingsGroup(oldGroup); Assert.IsNull(returnedOldGroup); }
/// <summary> /// Returns a list of <see cref="SettingsPropertyDescriptor"/> objects describing each property belonging /// to a settings group. /// </summary> public static List<SettingsPropertyDescriptor> ListSettingsProperties(SettingsGroupDescriptor group) { Type settingsClass = Type.GetType(group.AssemblyQualifiedTypeName); return CollectionUtils.Map<PropertyInfo, SettingsPropertyDescriptor, List<SettingsPropertyDescriptor>>( SettingsClassMetaDataReader.GetSettingsProperties(settingsClass), delegate(PropertyInfo p) { SettingsPropertyDescriptor info = new SettingsPropertyDescriptor( SettingsClassMetaDataReader.GetName(p), SettingsClassMetaDataReader.GetType(p).FullName, SettingsClassMetaDataReader.GetDescription(p), SettingsClassMetaDataReader.GetScope(p), SettingsClassMetaDataReader.GetDefaultValue(p)); return info; }); }
public SettingsGroupDescriptor GetPreviousSettingsGroup(SettingsGroupDescriptor @group) { var newGroup = new SettingsGroupDescriptor(@group.Name, new Version(0, 9), @group.Description, @group.AssemblyQualifiedTypeName, @group.HasUserScopedSettings); var matchingSetting = FindSetting(@group); var previousSetting = FindSetting(newGroup); if (matchingSetting == null) { if (previousSetting != null) { return(newGroup); } return(null); } if (previousSetting == null) { var newSetting = new Setting { Group = newGroup, Values = new Dictionary <string, string>() }; _settingsList.Add(newSetting); foreach (var key in matchingSetting.Values.Keys) { var val = matchingSetting.Values[key]; newSetting.Values[key] = val + TestString; } } return(newGroup); }
public void SettingsStorePutGet() { const string testVal = "A man, a plan, a canal, panama"; var store = new SystemConfigurationSettingsStore(); var settings = new AppSettings(); var group = new SettingsGroupDescriptor(typeof (AppSettings)); settings.App = testVal; var dic = new Dictionary<string, string>(); dic.Add(AppSettings.PropertyApp, settings.App); store.PutSettingsValues(group, null, null, dic); var resultDic = store.GetSettingsValues(group, null, null); string val; Assert.IsTrue(resultDic.TryGetValue(AppSettings.PropertyApp, out val)); Assert.AreEqual(val, testVal); }
public override void SetPropertyValues(SettingsContext context, SettingsPropertyValueCollection collection) { lock (_syncLock) { // locate dirty values that should be saved var valuesToStore = new Dictionary <string, string>(); foreach (SettingsPropertyValue value in collection) { //If storing the shared values, we store everything, otherwise only store user values. if (value.IsDirty) { valuesToStore[value.Name] = (string)value.SerializedValue; } } if (valuesToStore.Count > 0) { var settingsClass = (Type)context["SettingsClassType"]; var settingsKey = (string)context["SettingsKey"]; var group = new SettingsGroupDescriptor(settingsClass); if (group.HasUserScopedSettings) { throw new ConfigurationErrorsException(SR.SystemConfigurationSettingsProviderUserSetting); } _store.PutSettingsValues(group, null, settingsKey, valuesToStore); // successfully saved user settings are no longer dirty foreach (var storedValue in valuesToStore) { collection[storedValue.Key].IsDirty = false; } } } }
public void PutSettingsValues(SettingsGroupDescriptor @group, string user, string instanceKey, Dictionary <string, string> dirtyValues) { foreach (var setting in _settingsList) { if (group.Name == setting.Group.Name && group.Version == setting.Group.Version) { foreach (var key in dirtyValues.Keys) { string val = dirtyValues[key]; setting.Values[key] = val; } return; } } var newSetting = new Setting { Group = @group, Values = dirtyValues }; _settingsList.Add(newSetting); }
public void PutSettingsValues(SettingsGroupDescriptor group, string user, string instanceKey, Dictionary <string, string> dirtyValues) { // note: if user == null, we are saving shared settings, if user is valued, we are saving user settings // but both are never edited as a single operation // the approach taken here is to create an XML document that represents a diff between // the default settings (as specified by the settings group meta-data) and the modified settings, // and store that document in the configuration store var service = Platform.GetService <IConfigurationService>(); using (service as IDisposable) using (var offlineCacheClient = _offlineCache.CreateClient()) { // first obtain the meta-data for the settings group properties var properties = ListSettingsProperties(group, service); // next we obtain any previously stored configuration document for this settings group var documentKey = new ConfigurationDocumentKey(group.Name, group.Version, user, instanceKey); var document = GetConfigurationDocument(service, documentKey); // parse document var parser = new SettingsParser(); var values = new Dictionary <string, string>(); parser.FromXml(document, values); // update the values that have changed foreach (var kvp in dirtyValues) { values[kvp.Key] = kvp.Value; } // now remove any values that are identical to the default values foreach (var property in properties) { string value; if (values.TryGetValue(property.Name, out value) && Equals(value, property.DefaultValue)) { values.Remove(property.Name); } } try { if (values.Count > 0) { // generate the document, update local cache and server document = parser.ToXml(values); offlineCacheClient.Put(documentKey, document); service.SetConfigurationDocument(new SetConfigurationDocumentRequest(documentKey, document)); } else { // every value is the same as the default, so the document can be removed // update local cache and server offlineCacheClient.Remove(documentKey); service.RemoveConfigurationDocument(new RemoveConfigurationDocumentRequest(documentKey)); } } catch (EndpointNotFoundException e) { Platform.Log(LogLevel.Debug, e, "Unable to save settings to configuration service."); } } }
public void ImportSettingsGroup(SettingsGroupDescriptor @group, List <SettingsPropertyDescriptor> properties) { }
/// <summary> /// Local store does not support import. /// </summary> public void ImportSettingsGroup(SettingsGroupDescriptor group, List<SettingsPropertyDescriptor> properties) { throw new NotSupportedException("Local settings store does not support the Import operation."); }
public SettingsGroupDescriptor GetPreviousSettingsGroup(SettingsGroupDescriptor group) { throw new NotSupportedException("Local settings store does not support retrieval of previous settings group."); }
public SettingsGroupDescriptor GetPreviousSettingsGroup(SettingsGroupDescriptor @group) { return(@group); }
internal SettingsStoreGroup(SettingsGroupDescriptor descriptor, ISettingsStore store) : base(descriptor) { _store = store; }
public static Type GetSettingsClass(SettingsGroupDescriptor group) { Type settingsClass = Type.GetType(group.AssemblyQualifiedTypeName, true); CheckType(settingsClass); return settingsClass; }
public void RemoveUserSettings(SettingsGroupDescriptor group, string user, string instanceKey) { //throw new NotSupportedException(); }
public void PutSettingsValues(SettingsGroupDescriptor group, string user, string instanceKey, Dictionary <string, string> dirtyValues) { }
public Dictionary <string, string> GetSettingsValues(SettingsGroupDescriptor group, string user, string instanceKey) { return(new Dictionary <string, string>()); }
public void ImportSettingsGroup(SettingsGroupDescriptor group, List <SettingsPropertyDescriptor> properties) { throw new NotSupportedException(); }
public SettingsGroupDescriptor GetPreviousSettingsGroup(SettingsGroupDescriptor group) { return(null); }
public void RemoveUserSettings(SettingsGroupDescriptor @group, string user, string instanceKey) { }
private void Upgrade(SettingsContext context, SettingsPropertyCollection properties, string user) { Type settingsClass = (Type)context["SettingsClassType"]; string settingsKey = (string)context["SettingsKey"]; bool isUserUpgrade = !String.IsNullOrEmpty(user); SettingsGroupDescriptor group = new SettingsGroupDescriptor(settingsClass); Dictionary<string, string> previousValues = GetPreviousSettingsValues(group, user, settingsKey); bool oldValuesExist = previousValues != null && previousValues.Count > 0; if (!oldValuesExist) return; //nothing to migrate. var upgradedValues = new SettingsPropertyValueCollection(); foreach (SettingsProperty property in properties) { if (isUserUpgrade && !IsUserScoped(property)) continue; string oldValue; if (!previousValues.TryGetValue(property.Name, out oldValue)) continue; //Unconditionally save every old value; let the store sort out what to do. upgradedValues.Add(new SettingsPropertyValue(property) { SerializedValue = oldValue, IsDirty = true }); } if (upgradedValues.Count > 0) SetPropertyValues(context, upgradedValues, user); }
public IList <SettingsPropertyDescriptor> ListSettingsProperties(SettingsGroupDescriptor @group) { Group g; return(_groups.TryGetValue(@group, out g) ? g.SettingsProperties : Enumerable.Empty <SettingsPropertyDescriptor>().ToList().AsReadOnly()); }
public ImportSettingsGroupRequest(SettingsGroupDescriptor group, List <SettingsPropertyDescriptor> properties) { this.Group = group; this.Properties = properties; }
protected Group(SettingsGroupDescriptor descriptor) { Descriptor = descriptor; }
public static Dictionary<string, string> CreateSettingsValues(Type type, MigrationScope migrationScope, SettingValue settingValue) { var values = new Dictionary<string, string>(); SettingsGroupDescriptor group = new SettingsGroupDescriptor(type); foreach (var property in SettingsPropertyDescriptor.ListSettingsProperties(group)) { var value = CreateSettingValue(property, migrationScope, settingValue); if (value != null) values[property.Name] = value; } return values; }
public LocallyInstalledGroup(SettingsGroupDescriptor descriptor) : base(descriptor) { _settingsClass = ApplicationSettingsHelper.GetSettingsClass(this.Descriptor); }
/// <summary> /// Unsupported. An exception will always be thrown. /// </summary> /// <param name="group"></param> /// <param name="user"></param> /// <param name="instanceKey"></param> /// <exception cref="NotSupportedException">always thrown</exception> public void RemoveUserSettings(SettingsGroupDescriptor group, string user, string instanceKey) { throw new NotSupportedException("Local settings store does not support removal of user settings."); }
/// <summary> /// Returns settings properties for specified group, assuming plugin containing group resides on local machine /// </summary> /// <param name="group"></param> /// <returns></returns> public IList<SettingsPropertyDescriptor> ListSettingsProperties(SettingsGroupDescriptor group) { return SettingsPropertyDescriptor.ListSettingsProperties(group); }
/// <summary> /// Local store does not support import. /// </summary> public void ImportSettingsGroup(SettingsGroupDescriptor group, List <SettingsPropertyDescriptor> properties) { throw new NotSupportedException("Local settings store does not support the Import operation."); }
public IList <SettingsPropertyDescriptor> ListSettingsProperties(SettingsGroupDescriptor @group) { return(new List <SettingsPropertyDescriptor>()); }
/// <summary> /// Returns settings groups installed on local machine /// </summary> /// <returns></returns> public IList <SettingsGroupDescriptor> ListSettingsGroups() { return(SettingsGroupDescriptor.ListInstalledSettingsGroups(false)); }
private SettingsPropertyValueCollection GetSharedPropertyValues(SettingsGroupDescriptor group, string settingsKey, SettingsPropertyCollection properties) { var sharedValues = new Dictionary<string, string>(); foreach (var sharedValue in _store.GetSettingsValues(group, null, settingsKey)) sharedValues[sharedValue.Key] = sharedValue.Value; return GetSettingsValues(properties, sharedValues); }
/// <summary> /// Returns settings properties for specified group, assuming plugin containing group resides on local machine /// </summary> /// <param name="group"></param> /// <returns></returns> public IList <SettingsPropertyDescriptor> ListSettingsProperties(SettingsGroupDescriptor group) { return(SettingsPropertyDescriptor.ListSettingsProperties(group)); }
public SettingsPropertyValueCollection GetPreviousSharedPropertyValues(SettingsContext context, SettingsPropertyCollection properties, string ignoredPreviousExeConfigFilename) { Type settingsClass = (Type)context["SettingsClassType"]; string settingsKey = (string)context["SettingsKey"]; var group = new SettingsGroupDescriptor(settingsClass); group = _store.GetPreviousSettingsGroup(group); return group == null ? new SettingsPropertyValueCollection() : GetSharedPropertyValues(group, settingsKey, properties); }
public void RemoveSettingsGroup(SettingsGroupDescriptor @group) { Setting settingToRemove = null; foreach (var setting in _settingsList) { if (group.Name == setting.Group.Name && group.Version == setting.Group.Version) { settingToRemove = setting; break; } } if (settingToRemove != null) _settingsList.Remove(settingToRemove); }
public void ImportSettingsGroup(SettingsGroupDescriptor group, List <SettingsPropertyDescriptor> properties) { Platform.GetService((IConfigurationService service) => service.ImportSettingsGroup(new ImportSettingsGroupRequest(group, properties))); }
public ListSettingsPropertiesRequest(SettingsGroupDescriptor group) { Group = group; }
public void MigrateSettings() { TestSettingsStore.Instance.Reset(); var settings = new MigrationAppSettings(); const string testVal1 = "A man, a plan, a canal, panama"; const string testVal2 = "Now is the time for all good men to come to the aide of their country"; settings.App1 = testVal1; settings.App2 = testVal2; settings.Save(); Assert.IsTrue(SettingsMigrator.MigrateSharedSettings(typeof (MigrationAppSettings), null)); var settings1a = new MigrationAppSettings(); Assert.AreEqual(settings1a.App1, testVal1); Assert.AreEqual(settings1a.App2, testVal2); Assert.AreEqual(settings1a.App3, MigrationAppSettings.DefaultValueApp); var group = new SettingsGroupDescriptor(typeof (MigrationAppSettings)); TestSettingsStore.Instance.GetPreviousSettingsGroup(group); TestSettingsStore.Instance.RemoveSettingsGroup(group); var settings2 = new MigrationAppSettings(); Assert.AreEqual(settings2.App1, MigrationAppSettings.DefaultValueApp); Assert.AreEqual(settings2.App2, MigrationAppSettings.DefaultValueApp); Assert.AreEqual(settings2.App3, MigrationAppSettings.DefaultValueApp); Assert.IsTrue(SettingsMigrator.MigrateSharedSettings(typeof (MigrationAppSettings), null)); var settings3 = new MigrationAppSettings(); Assert.AreEqual(settings3.App1, testVal1 + TestSettingsStore.TestString); Assert.AreEqual(settings3.App2, testVal2 + TestSettingsStore.TestString); Assert.AreEqual(settings3.App3, MigrationAppSettings.DefaultValueApp); }
private Dictionary<string, string> GetPreviousSettingsValues(SettingsGroupDescriptor group, string user, string settingsKey) { var allGroups = _store.ListSettingsGroups(); var lessGroups = CollectionUtils.Select(allGroups, other => other.AssemblyQualifiedTypeName == group.AssemblyQualifiedTypeName && other.Version < group.Version); // sort descending lessGroups.Sort((other1, other2) => other2.Version.CompareTo(other1.Version)); if (lessGroups.Count == 0) return null; foreach (var g in lessGroups) { Dictionary<string, string> userValues = null; if (!String.IsNullOrEmpty(user)) { userValues = _store.GetSettingsValues(g, user, settingsKey); if (userValues == null || userValues.Count == 0) continue; } var values = new Dictionary<string, string>(); foreach (var binaryDefault in _store.ListSettingsProperties(g)) values[binaryDefault.Name] = binaryDefault.DefaultValue; foreach (var userDefault in _store.GetSettingsValues(g, null, settingsKey)) values[userDefault.Key] = userDefault.Value; if (userValues != null) { foreach (var userValue in userValues) values[userValue.Key] = userValue.Value; } return values; } return null; }
public Dictionary <string, string> GetSettingsValues(SettingsGroupDescriptor @group, string user, string instanceKey) { Group g; return(_groups.TryGetValue(@group, out g) ? g.GetSettingsValues(user, instanceKey) : GetEmptySettingsDictionary()); }
public bool CanUpgradeSharedPropertyValues(SettingsContext context) { Type settingsClass = (Type)context["SettingsClassType"]; string settingsKey = (string)context["SettingsKey"]; var group = new SettingsGroupDescriptor(settingsClass); var storedValues = _store.GetSettingsValues(group, null, settingsKey); return storedValues == null || storedValues.Count == 0; }
public Dictionary<string, string> GetSettingsValues(SettingsGroupDescriptor @group, string user, string instanceKey) { foreach (var setting in _settingsList) { if (group.Name == setting.Group.Name && group.Version == setting.Group.Version) { return setting.Values; } } return new Dictionary<string, string>(); }
public SettingsPropertyValueCollection GetSharedPropertyValues(SettingsContext context, SettingsPropertyCollection properties) { Type settingsClass = (Type)context["SettingsClassType"]; string settingsKey = (string)context["SettingsKey"]; var group = new SettingsGroupDescriptor(settingsClass); return GetSharedPropertyValues(group, settingsKey, properties); }
public void PutSettingsValues(SettingsGroupDescriptor @group, string user, string instanceKey, Dictionary<string, string> dirtyValues) { foreach (var setting in _settingsList) { if (group.Name == setting.Group.Name && group.Version == setting.Group.Version) { foreach (var key in dirtyValues.Keys) { string val = dirtyValues[key]; setting.Values[key] = val; } return; } } var newSetting = new Setting { Group = @group, Values = dirtyValues }; _settingsList.Add(newSetting); }