internal static void MigrateUserSettings(ApplicationSettingsBase settings)
        {
            if (settings is IMigrateSettings)
            {
                IMigrateSettings customMigrator = (IMigrateSettings)settings;
                foreach (SettingsProperty property in settings.Properties)
                {
                    if (!SettingsPropertyExtensions.IsUserScoped(property))
                    {
                        continue;
                    }

                    object previousValue = settings.GetPreviousVersion(property.Name);

                    //need to do this to force the values to load before accessing the PropertyValues in order to migrate,
                    //otherwise the SettingsPropertyValue will always be null.
                    var iForceSettingsPropertyValuesToLoad = settings[property.Name];
                    var currentValue = settings.PropertyValues[property.Name];
                    MigrateProperty(customMigrator, MigrationScope.User, currentValue, previousValue);
                }
            }
            else
            {
                settings.Upgrade();
            }

            //Don't need to reload because the user settings will be current.
            SaveIfDirty(settings);
        }
 public static SettingsPropertyDescriptor GetDescriptor(SettingsProperty property)
 {
     return(new SettingsPropertyDescriptor(property.Name, property.PropertyType.FullName,
                                           SettingsPropertyExtensions.GetDescription(property), GetScope(property), property.DefaultValue as string));
 }
 public static SettingScope GetScope(SettingsProperty property)
 {
     return(SettingsPropertyExtensions.IsUserScoped(property) ? SettingScope.User : SettingScope.Application);
 }
Exemplo n.º 4
0
 private static bool IsUserScoped(SettingsProperty property)
 {
     return(SettingsPropertyExtensions.IsUserScoped(property));
 }