public PresetsPerModeBackup(PresetPerModeBase set) { var backup = new Backup(); if (set.Apps.IsActuallyEnabled()) { backup.Apps = AcSettingsHolder.AppsPresets.ExportToPresetData(); } if (set.Audio.IsActuallyEnabled()) { backup.Audio = AcSettingsHolder.AudioPresets.ExportToPresetData(); } if (set.Video.IsActuallyEnabled()) { backup.Video = AcSettingsHolder.VideoPresets.ExportToPresetData(); } if (set.Controls.IsActuallyEnabled()) { try { backup.Controls = File.ReadAllText(AcSettingsHolder.Controls.Filename); } catch (Exception e) { Logging.Warning(e); } } try { File.WriteAllText(BackupFilename, JsonConvert.SerializeObject(backup)); } catch (Exception e) { throw new InformativeException("Can’t make a backup before loading presets for mode", e); } }
public void Extend(PresetPerModeBase ext) { foreach (var p in GetType().GetProperties().Where(x => x.PropertyType == typeof(CustomPresetEntryBase))) { var e = (CustomPresetEntryBase)p.GetValue(ext); if (e.IsActuallyEnabled()) { NotEmpty = true; ((CustomPresetEntryBase)p.GetValue(this)).CopyFrom(e); } } }