public static void OverrideValues(UndoRedoStack urs, ISettingsPropertyDefinition current, ISettingsPropertyDefinition @new) { if (SettingsUtils.Equals(current, @new)) { return; } switch (current.SettingType) { case SettingType.Bool: urs.Do(new SetValueTypeAction <bool>(current.PropertyReference, (bool)@new.PropertyReference.Value)); break; case SettingType.Int: urs.Do(new SetValueTypeAction <int>(current.PropertyReference, (int)@new.PropertyReference.Value)); break; case SettingType.Float: urs.Do(new SetValueTypeAction <float>(current.PropertyReference, (float)@new.PropertyReference.Value)); break; case SettingType.String: urs.Do(new SetStringAction(current.PropertyReference, (string)@new.PropertyReference.Value)); break; case SettingType.Dropdown: urs.Do(new SetDropdownIndexAction(current.PropertyReference, SettingsUtils.GetSelector(@new.PropertyReference.Value))); break; } }
public static void OverrideValues(UndoRedoStack urs, ISettingsPropertyDefinition current, ISettingsPropertyDefinition @new) { if (SettingsUtils.Equals(current, @new)) { return; } switch (current.SettingType) { case SettingType.Bool when @new.PropertyReference.Value is bool val: urs.Do(new SetValueTypeAction <bool>(current.PropertyReference, val)); break; case SettingType.Int when @new.PropertyReference.Value is int val: urs.Do(new SetValueTypeAction <int>(current.PropertyReference, val)); break; case SettingType.Float when @new.PropertyReference.Value is float val: urs.Do(new SetValueTypeAction <float>(current.PropertyReference, val)); break; case SettingType.String when @new.PropertyReference.Value is string val: urs.Do(new SetStringAction(current.PropertyReference, val)); break; case SettingType.Dropdown when @new.PropertyReference.Value is { } val: urs.Do(new SetSelectedIndexAction(current.PropertyReference, new SelectedIndexWrapper(val))); break; } }