Beispiel #1
0
		public SettingsPropertyMigrationValues(string propertyName, MigrationScope migrationScope, object currentValue, object previousValue)
        {
			PropertyName = propertyName;
			MigrationScope = migrationScope;
            CurrentValue = currentValue;
            PreviousValue = previousValue;
        }
Beispiel #2
0
        private static void ValidateStoredValues(Type type, MigrationScope migrationScope, SettingValue expectedValue)
        {
            var settings = ApplicationSettingsHelper.GetSettingsClassInstance(type);

            foreach (SettingsProperty property in settings.Properties)
            {
                string expected = CreateSettingValue(property, migrationScope, expectedValue);
                if (migrationScope == MigrationScope.User)
                {
                    if (SettingsPropertyExtensions.IsAppScoped(property))
                    {
                        continue;
                    }

                    string actual = (string)settings[property.Name];
                    Assert.AreEqual(expected, actual);
                }
                else
                {
                    if (SettingsPropertyExtensions.IsAppScoped(property))
                    {
                        string actual = (string)settings[property.Name];
                        Assert.AreEqual(expected, actual);
                    }

                    string shared = (string)ApplicationSettingsExtensions.GetSharedPropertyValue(settings, property.Name);
                    Assert.AreEqual(expected, shared);
                }
            }
        }
        private void ValidateValuesInConfig(MigrationScope migrationScope, SettingValue settingValue)
        {
            var configuration = GetExeConfiguration();
            var values        = SystemConfigurationHelper.GetSettingsValues(configuration, _settingsClass);

            ValidateValues(values, migrationScope, settingValue);
        }
Beispiel #4
0
 public SettingsPropertyMigrationValues(string propertyName, MigrationScope migrationScope, object currentValue, object previousValue)
 {
     PropertyName   = propertyName;
     MigrationScope = migrationScope;
     CurrentValue   = currentValue;
     PreviousValue  = previousValue;
 }
Beispiel #5
0
        private void ValidateValuesInConfig(Type settingsClass, MigrationScope migrationScope, SettingValue settingValue)
        {
            var configuration = GetExeConfiguration();
            var values        = configuration.GetSettingsValues(settingsClass);

            ValidateValues(settingsClass, values, migrationScope, settingValue);
        }
		private static void MigrateProperty(IMigrateSettings customMigrator, MigrationScope migrationScope, 
		                                    SettingsPropertyValue currentValue, object previousValue)
		{
			var migrationValues = new SettingsPropertyMigrationValues(
				currentValue.Property.Name, migrationScope, 
				currentValue.PropertyValue, previousValue);

			customMigrator.MigrateSettingsProperty(migrationValues);
			if (!Equals(migrationValues.CurrentValue, currentValue.PropertyValue))
				currentValue.PropertyValue = migrationValues.CurrentValue;
		}
        private static void MigrateProperty(IMigrateSettings customMigrator, MigrationScope migrationScope,
                                            SettingsPropertyValue currentValue, object previousValue)
        {
            var migrationValues = new SettingsPropertyMigrationValues(
                currentValue.Property.Name, migrationScope,
                currentValue.PropertyValue, previousValue);

            customMigrator.MigrateSettingsProperty(migrationValues);
            if (!Equals(migrationValues.CurrentValue, currentValue.PropertyValue))
            {
                currentValue.PropertyValue = migrationValues.CurrentValue;
            }
        }
Beispiel #8
0
        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);
        }
Beispiel #9
0
        public static string CreateSettingValue(SettingsPropertyDescriptor property, MigrationScope migrationScope, SettingValue settingValue)
        {
            if (settingValue == SettingValue.Default)
            {
                return(property.DefaultValue);
            }

            if (migrationScope == MigrationScope.User && property.Scope == SettingScope.Application)
            {
                return(null);
            }

            if (property.Scope == SettingScope.User && migrationScope == MigrationScope.Shared)
            {
                return(CreateUserDefaultSettingValue(property.Name, settingValue));
            }

            return(CreateSettingValue(property.Name, settingValue));
        }
Beispiel #10
0
		public static string CreateSettingValue(SettingsPropertyDescriptor property, MigrationScope migrationScope, SettingValue settingValue)
		{
			if (settingValue == SettingValue.Default)
				return property.DefaultValue;

			if (migrationScope == MigrationScope.User && property.Scope == SettingScope.Application)
				return null;

			if (property.Scope == SettingScope.User && migrationScope == MigrationScope.Shared)
				return CreateUserDefaultSettingValue(property.Name, settingValue);

			return CreateSettingValue(property.Name, settingValue);
		}
Beispiel #11
0
 public static string CreateSettingValue(PropertyInfo property, MigrationScope migrationScope, SettingValue settingValue)
 {
     return(CreateSettingValue(new SettingsPropertyDescriptor(property), migrationScope, settingValue));
 }
Beispiel #12
0
 public static string CreateSettingValue(SettingsProperty property, MigrationScope migrationScope, SettingValue settingValue)
 {
     return(CreateSettingValue(SettingsPropertyHelper.GetDescriptor(property), migrationScope, settingValue));
 }
Beispiel #13
0
        public static SettingsPropertyValue CreateSettingsPropertyValue(SettingsProperty property, MigrationScope migrationScope, SettingValue settingValue)
        {
            var value = CreateSettingValue(property, migrationScope, settingValue);

            if (value == null)
            {
                return(null);
            }

            return(new SettingsPropertyValue(property)
            {
                SerializedValue = value
            });
        }
		private void ValidateValuesInConfig(Type settingsClass, MigrationScope migrationScope, SettingValue settingValue)
		{
			var configuration = GetExeConfiguration();
			var values = configuration.GetSettingsValues(settingsClass);
			ValidateValues(settingsClass, values, migrationScope, settingValue);
		}
        private void ValidateValues(Dictionary <string, string> values, MigrationScope migrationScope, SettingValue settingValue)
        {
            var expected = CreateSettingsValues(_settingsClass, migrationScope, settingValue);

            ValidateValues(values, expected);
        }
		private void ValidateValues(Dictionary<string, string> values, MigrationScope migrationScope, SettingValue settingValue)
		{
			if (settingValue == SettingValue.Default)
			{
				Assert.AreEqual(0, values.Count);
				return;
			}

			var expected = CreateSettingsValues(_settingsClass, migrationScope, settingValue);
			ValidateValues(values, expected);
		}
Beispiel #17
0
		public static SettingsPropertyValue CreateSettingsPropertyValue(SettingsProperty property, MigrationScope migrationScope, SettingValue settingValue)
		{
			var value = CreateSettingValue(property, migrationScope, settingValue);
			if (value == null)
				return null;

			return new SettingsPropertyValue(property) { SerializedValue = value };
		}
Beispiel #18
0
		private static void ValidateStoredValues(Type type, MigrationScope migrationScope, SettingValue expectedValue)
		{
			var settings = ApplicationSettingsHelper.GetSettingsClassInstance(type);
			foreach (SettingsProperty property in settings.Properties)
			{
				string expected = CreateSettingValue(property, migrationScope, expectedValue);
				if (migrationScope == MigrationScope.User)
				{
					if (SettingsPropertyExtensions.IsAppScoped(property))
						continue;

					string actual = (string)settings[property.Name];
					Assert.AreEqual(expected, actual);
				}
				else
				{
					if (SettingsPropertyExtensions.IsAppScoped(property))
					{
						string actual = (string)settings[property.Name];
						Assert.AreEqual(expected, actual);
					}

					string shared = (string)ApplicationSettingsExtensions.GetSharedPropertyValue(settings, property.Name);
					Assert.AreEqual(expected, shared);
				}
			}
		}
		private void ValidateValues(Dictionary<string, string> values, MigrationScope migrationScope, SettingValue settingValue)
		{
			var expected = CreateSettingsValues(_settingsClass, migrationScope, settingValue);
			ValidateValues(values, expected);
		}
		private void ValidateValuesInConfig(MigrationScope migrationScope, SettingValue settingValue)
		{
			var configuration = GetExeConfiguration();
			var values = SystemConfigurationHelper.GetSettingsValues(configuration, _settingsClass);
			ValidateValues(values, migrationScope, settingValue);
		}
Beispiel #21
0
		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;
		}
Beispiel #22
0
		public static string CreateSettingValue(SettingsProperty property, MigrationScope migrationScope, SettingValue settingValue)
		{
			return CreateSettingValue(SettingsPropertyHelper.GetDescriptor(property), migrationScope, settingValue);
		}
Beispiel #23
0
		public static string CreateSettingValue(PropertyInfo property, MigrationScope migrationScope, SettingValue settingValue)
		{
			return CreateSettingValue(new SettingsPropertyDescriptor(property), migrationScope, settingValue);
		}