Files
VRCX/VRCXStorage.cs
2019-08-16 22:53:04 +09:00

67 lines
1.5 KiB
C#

// 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;
}
}
}
}