/// <summary>
/// Abstract SettingsProvider method
/// </summary>
public override void SetPropertyValues(SettingsContext context, SettingsPropertyValueCollection values)
{
string sectionName = GetSectionName(context);
IDictionary roamingUserSettings = new Hashtable();
IDictionary localUserSettings = new Hashtable();
foreach (SettingsPropertyValue value in values)
{
SettingsProperty setting = value.Property;
bool isUserSetting = IsUserSetting(setting);
if (value.IsDirty)
{
if (isUserSetting)
{
bool isRoaming = IsRoamingSetting(setting);
StoredSetting ss = new StoredSetting(setting.SerializeAs, SerializeToXmlElement(setting, value));
if (isRoaming)
{
roamingUserSettings[setting.Name] = ss;
}
else
{
localUserSettings[setting.Name] = ss;
}
value.IsDirty = false; //reset IsDirty
}
else
{
// This is an app-scoped or connection string setting that has been written to.
// We don't support saving these.
}
}
}
// Semi-hack: If there are roamable settings, let's write them before local settings so if a handler
// declaration is necessary, it goes in the roaming config file in preference to the local config file.
if (roamingUserSettings.Count > 0)
{
ClientSettingsStore.WriteSettings(sectionName, true, roamingUserSettings);
}
if (localUserSettings.Count > 0)
{
ClientSettingsStore.WriteSettings(sectionName, false, localUserSettings);
}
}