using System; using System.Runtime.InteropServices; using NitroxModel.Platforms.OS.Shared; using NitroxModel.Platforms.OS.Windows; namespace NitroxModel.Helper; /// /// Simple Key-Value store that works cross-platform.
///
/// /// /// On Windows:
/// Backend is , which uses the registry. /// If you want to view/edit the KeyStore, open regedit and navigate to HKEY_CURRENT_USER\SOFTWARE\Nitrox\(keyname) ///
/// /// On Linux:
/// Backend is , which uses a file. /// If you want to view/edit the KeyStore, open $HOME/.config/Nitrox/nitrox.cfg in your favourite text editor. ///
///
public static class KeyValueStore { public static IKeyValueStore Instance { get; } = GetKeyValueStoreForPlatform(); private static IKeyValueStore GetKeyValueStoreForPlatform() { if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { // Use registry on Windows return new RegistryKeyValueStore(); } // if platform isn't Windows, it doesn't have a registry // use a config file for storage this should work on most platforms return new ConfigFileKeyValueStore(); } }