Example #1
0
        public override SettingsPropertyValueCollection GetPropertyValues(SettingsContext context, SettingsPropertyCollection props)
        {
            XmlSettingsFile localFile              = XmlSettingsFile.GetLocalSettingsFile(GetTypeFromContext(context));
            XmlSettingsFile roamingFile            = XmlSettingsFile.GetRoamingSettingsFile(GetTypeFromContext(context));
            SettingsPropertyValueCollection values = new SettingsPropertyValueCollection();

            foreach (SettingsProperty setting in props)
            {
                SettingsPropertyValue value = new SettingsPropertyValue(setting);
                value.IsDirty = false;

                if (IsRoaming(setting))
                {
                    value.SerializedValue = roamingFile.GetValue(setting);
                }
                else
                {
                    value.SerializedValue = localFile.GetValue(setting);
                }

                values.Add(value);
            }

            return(values);
        }
Example #2
0
        public override void SetPropertyValues(SettingsContext context, SettingsPropertyValueCollection propvals)
        {
            XmlSettingsFile localFile   = XmlSettingsFile.GetLocalSettingsFile(GetTypeFromContext(context));
            XmlSettingsFile roamingFile = XmlSettingsFile.GetRoamingSettingsFile(GetTypeFromContext(context));

            foreach (SettingsPropertyValue propval in propvals)
            {
                if (IsRoaming(propval.Property))
                {
                    roamingFile.SetValue(propval);
                }
                else
                {
                    localFile.SetValue(propval);
                }
            }

            localFile.Save();
            roamingFile.Save();
        }