Ejemplo n.º 1
0
        private static void SetValueOnProperty(PropertyInfo property, SettingsToggleSetting setting, IRoutineSettings settingsInstance, bool checkedOn)
        {
            switch (setting.Type)
            {
            case SettingType.Boolean:
                property.SetValue(settingsInstance,
                                  checkedOn
                            ? Convert.ChangeType(setting.BoolCheckedValue, property.PropertyType)
                            : Convert.ChangeType(setting.BoolUncheckedValue, property.PropertyType));
                break;

            case SettingType.Integer:
                property.SetValue(settingsInstance,
                                  checkedOn
                            ? Convert.ChangeType(setting.IntCheckedValue, property.PropertyType)
                            : Convert.ChangeType(setting.IntUncheckedValue, property.PropertyType));
                break;

            case SettingType.Float:
                property.SetValue(settingsInstance,
                                  checkedOn
                            ? Convert.ChangeType(setting.FloatCheckedValue, property.PropertyType)
                            : Convert.ChangeType(setting.FloatUncheckedValue, property.PropertyType));
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Ejemplo n.º 2
0
        public static bool SettingToggleSettingMatchesProperty(SettingsToggleSetting setting, PropertyInfo property, IRoutineSettings iroutineSettingsInstance)
        {
            switch (setting.Type)
            {
            case SettingType.Boolean:
                var boolValue = (bool)property.GetValue(iroutineSettingsInstance, null);
                return(setting.BoolCheckedValue == boolValue);

            case SettingType.Integer:
                var intValue = (int)property.GetValue(iroutineSettingsInstance, null);
                return(setting.IntCheckedValue == intValue);

            case SettingType.Float:
                var floatValue = (float)property.GetValue(iroutineSettingsInstance, null);
                return(setting.FloatCheckedValue == floatValue);

            case SettingType.None:
                return(false);

            default:
                throw new ArgumentOutOfRangeException();
            }
        }