mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-19 14:53:50 +02:00
Initial commit
This commit is contained in:
67
VRCXStorage.cs
Normal file
67
VRCXStorage.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
// Copyright(c) 2019 pypy. All rights reserved.
|
||||
//
|
||||
// This work is licensed under the terms of the MIT license.
|
||||
// For a copy, see <https://opensource.org/licenses/MIT>.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace VRCX
|
||||
{
|
||||
public class VRCXStorage
|
||||
{
|
||||
private static Dictionary<string, string> m_Storage = new Dictionary<string, string>();
|
||||
|
||||
public static void Load()
|
||||
{
|
||||
JsonSerializer.Deserialize(Application.StartupPath + "/VRCX.json", ref m_Storage);
|
||||
}
|
||||
|
||||
public static void Save()
|
||||
{
|
||||
JsonSerializer.Serialize(Application.StartupPath + "/VRCX.json", m_Storage);
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
lock (m_Storage)
|
||||
{
|
||||
m_Storage.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
public void Flush()
|
||||
{
|
||||
lock (m_Storage)
|
||||
{
|
||||
Save();
|
||||
}
|
||||
}
|
||||
|
||||
public bool Remove(string key)
|
||||
{
|
||||
lock (m_Storage)
|
||||
{
|
||||
return m_Storage.Remove(key);
|
||||
}
|
||||
}
|
||||
|
||||
public string Get(string key)
|
||||
{
|
||||
lock (m_Storage)
|
||||
{
|
||||
return m_Storage.TryGetValue(key, out string value)
|
||||
? value
|
||||
: string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
public void Set(string key, string value)
|
||||
{
|
||||
lock (m_Storage)
|
||||
{
|
||||
m_Storage[key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user