mirror of
https://github.com/rmcrackan/Libation.git
synced 2026-03-30 12:53:45 -04:00
- Move all settings file logic into new LibationFiles class - Configuration.LibationFiles is a singleton instance of the LibationFiles class. - A LibationFiles instance is bound to a single appsettings.json path. All updates to LibationFiles location are updated in that appsettings.json file - Unify initial setup and settings validation process - Add LibationSetup which handles all startup validation of settings files and prompts users for setup if needed - Added a new LibationUiBase.Tests test project with tests for various
41 lines
1.1 KiB
C#
41 lines
1.1 KiB
C#
using System;
|
|
using System.Diagnostics;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using Dinah.Core;
|
|
using FileManager;
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
#nullable enable
|
|
namespace LibationFileManager
|
|
{
|
|
public partial class Configuration : PropertyChangeFilter
|
|
{
|
|
|
|
#region singleton stuff
|
|
|
|
public static Configuration CreateMockInstance()
|
|
{
|
|
#if !DEBUG
|
|
if (!new StackTrace().GetFrames().Select(f => f.GetMethod()?.DeclaringType?.Assembly.GetName().Name).Any(f => f?.EndsWith(".Tests") ?? false))
|
|
throw new InvalidOperationException($"Can only mock {nameof(Configuration)} in Debug mode or in test assemblies.");
|
|
#endif
|
|
|
|
var mockInstance = new Configuration() { persistentDictionary = new MockPersistentDictionary() };
|
|
mockInstance.SetString("Light", "ThemeVariant");
|
|
Instance = mockInstance;
|
|
return mockInstance;
|
|
}
|
|
public static void RestoreSingletonInstance()
|
|
{
|
|
Instance = s_SingletonInstance;
|
|
}
|
|
private static readonly Configuration s_SingletonInstance = new();
|
|
public static Configuration Instance { get; private set; } = s_SingletonInstance;
|
|
|
|
|
|
private Configuration() { }
|
|
#endregion
|
|
}
|
|
}
|