From bbeae31fc42aac84bae75d018ddeb1a36fcca1e3 Mon Sep 17 00:00:00 2001 From: Ionite Date: Sun, 9 Jul 2023 17:12:02 -0400 Subject: [PATCH] Add MockSettingsManager for design mode without IO --- StabilityMatrix.Avalonia/DesignData/DesignData.cs | 2 +- .../DesignData/MockSettingsManager.cs | 9 +++++++++ StabilityMatrix.Core/Services/SettingsManager.cs | 4 ++-- 3 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 StabilityMatrix.Avalonia/DesignData/MockSettingsManager.cs diff --git a/StabilityMatrix.Avalonia/DesignData/DesignData.cs b/StabilityMatrix.Avalonia/DesignData/DesignData.cs index 9233c046..d3895468 100644 --- a/StabilityMatrix.Avalonia/DesignData/DesignData.cs +++ b/StabilityMatrix.Avalonia/DesignData/DesignData.cs @@ -17,7 +17,7 @@ public static class DesignData { static DesignData() { - var settingsManager = new SettingsManager + var settingsManager = new MockSettingsManager { Settings = { diff --git a/StabilityMatrix.Avalonia/DesignData/MockSettingsManager.cs b/StabilityMatrix.Avalonia/DesignData/MockSettingsManager.cs new file mode 100644 index 00000000..86564211 --- /dev/null +++ b/StabilityMatrix.Avalonia/DesignData/MockSettingsManager.cs @@ -0,0 +1,9 @@ +using StabilityMatrix.Core.Services; + +namespace StabilityMatrix.Avalonia.DesignData; + +public class MockSettingsManager : SettingsManager +{ + protected override void LoadSettings() {} + protected override void SaveSettings() {} +} diff --git a/StabilityMatrix.Core/Services/SettingsManager.cs b/StabilityMatrix.Core/Services/SettingsManager.cs index 82d56d85..0b9539b8 100644 --- a/StabilityMatrix.Core/Services/SettingsManager.cs +++ b/StabilityMatrix.Core/Services/SettingsManager.cs @@ -423,7 +423,7 @@ public class SettingsManager : ISettingsManager /// Loads settings from the settings file /// If the settings file does not exist, it will be created with default values /// - private void LoadSettings() + protected virtual void LoadSettings() { FileLock.EnterReadLock(); try @@ -451,7 +451,7 @@ public class SettingsManager : ISettingsManager } } - private void SaveSettings() + protected virtual void SaveSettings() { FileLock.TryEnterWriteLock(100000); try