예제 #1
0
        /// <devdoc>
        ///     Abstract SettingsProvider method
        /// </devdoc>
        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) {
                Store.WriteSettings(sectionName, true, roamingUserSettings);
            }

            if (localUserSettings.Count > 0) {
                Store.WriteSettings(sectionName, false, localUserSettings);
            }
        }
 public override void SetPropertyValues(SettingsContext context, SettingsPropertyValueCollection values)
 {
     string sectionName = this.GetSectionName(context);
     IDictionary newSettings = new Hashtable();
     IDictionary dictionary2 = new Hashtable();
     foreach (SettingsPropertyValue value2 in values)
     {
         SettingsProperty property = value2.Property;
         bool flag = this.IsUserSetting(property);
         if (value2.IsDirty && flag)
         {
             bool flag2 = IsRoamingSetting(property);
             StoredSetting setting = new StoredSetting(property.SerializeAs, this.SerializeToXmlElement(property, value2));
             if (flag2)
             {
                 newSettings[property.Name] = setting;
             }
             else
             {
                 dictionary2[property.Name] = setting;
             }
             value2.IsDirty = false;
         }
     }
     if (newSettings.Count > 0)
     {
         this.Store.WriteSettings(sectionName, true, newSettings);
     }
     if (dictionary2.Count > 0)
     {
         this.Store.WriteSettings(sectionName, false, dictionary2);
     }
 }
        /// <devdoc>
        ///     Abstract SettingsProvider method
        /// </devdoc>
        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.
                    }
                }
            }
            
            if (roamingUserSettings.Count > 0) {
                Store.WriteSettings(sectionName, true, roamingUserSettings);
            }

            if (localUserSettings.Count > 0) {
                Store.WriteSettings(sectionName, false, localUserSettings);
            }
        }