mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-26 10:13:48 +02:00
make singleton
This commit is contained in:
@@ -10,11 +10,17 @@ namespace VRCX
|
||||
{
|
||||
public class Discord
|
||||
{
|
||||
public static Discord Instance { get; private set; }
|
||||
private static readonly ReaderWriterLockSlim m_Lock = new ReaderWriterLockSlim();
|
||||
private static readonly RichPresence m_Presence = new RichPresence();
|
||||
private static Thread m_Thread;
|
||||
private static bool m_Active;
|
||||
|
||||
static Discord()
|
||||
{
|
||||
Instance = new Discord();
|
||||
}
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
m_Thread = new Thread(() =>
|
||||
|
||||
@@ -20,6 +20,7 @@ namespace VRCX
|
||||
|
||||
public class LogWatcher
|
||||
{
|
||||
public static LogWatcher Instance { get; private set; }
|
||||
private static readonly ReaderWriterLockSlim m_Lock = new ReaderWriterLockSlim();
|
||||
private static List<string[]> m_GameLog = new List<string[]>();
|
||||
private static Thread m_Thread;
|
||||
@@ -28,6 +29,11 @@ namespace VRCX
|
||||
// NOTE
|
||||
// FileSystemWatcher() is unreliable
|
||||
|
||||
static LogWatcher()
|
||||
{
|
||||
Instance = new LogWatcher();
|
||||
}
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
m_Thread = new Thread(() =>
|
||||
|
||||
10
MainForm.cs
10
MainForm.cs
@@ -41,11 +41,11 @@ namespace VRCX
|
||||
{
|
||||
CamelCaseJavascriptNames = false
|
||||
};
|
||||
Browser.JavascriptObjectRepository.Register("VRCX", new VRCX(), true, options);
|
||||
Browser.JavascriptObjectRepository.Register("VRCXStorage", new VRCXStorage(), false, options);
|
||||
Browser.JavascriptObjectRepository.Register("SQLite", new SQLite(), true, options);
|
||||
Browser.JavascriptObjectRepository.Register("LogWatcher", new LogWatcher(), true, options);
|
||||
Browser.JavascriptObjectRepository.Register("Discord", new Discord(), true, options);
|
||||
Browser.JavascriptObjectRepository.Register("VRCX", VRCX.Instance, true, options);
|
||||
Browser.JavascriptObjectRepository.Register("VRCXStorage", VRCXStorage.Instance, false, options);
|
||||
Browser.JavascriptObjectRepository.Register("SQLite", SQLite.Instance, true, options);
|
||||
Browser.JavascriptObjectRepository.Register("LogWatcher", LogWatcher.Instance, true, options);
|
||||
Browser.JavascriptObjectRepository.Register("Discord", Discord.Instance, true, options);
|
||||
Browser.IsBrowserInitializedChanged += (A, B) =>
|
||||
{
|
||||
// Browser.ShowDevTools();
|
||||
|
||||
@@ -9,9 +9,15 @@ namespace VRCX
|
||||
{
|
||||
public class SQLite
|
||||
{
|
||||
public static SQLite Instance { get; private set; }
|
||||
private static readonly ReaderWriterLockSlim m_Lock = new ReaderWriterLockSlim();
|
||||
private static SQLiteConnection m_Connection;
|
||||
|
||||
static SQLite()
|
||||
{
|
||||
Instance = new SQLite();
|
||||
}
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
m_Connection = new SQLiteConnection($"Data Source={Application.StartupPath}/VRCX.sqlite;Version=3");
|
||||
|
||||
7
VRCX.cs
7
VRCX.cs
@@ -15,6 +15,13 @@ namespace VRCX
|
||||
{
|
||||
public class VRCX
|
||||
{
|
||||
public static VRCX Instance { get; private set; }
|
||||
|
||||
static VRCX()
|
||||
{
|
||||
Instance = new VRCX();
|
||||
}
|
||||
|
||||
public void ShowDevTools()
|
||||
{
|
||||
try
|
||||
|
||||
@@ -11,10 +11,16 @@ namespace VRCX
|
||||
{
|
||||
public class VRCXStorage
|
||||
{
|
||||
public static VRCXStorage Instance { get; private set; }
|
||||
private static readonly ReaderWriterLockSlim m_Lock = new ReaderWriterLockSlim();
|
||||
private static Dictionary<string, string> m_Storage = new Dictionary<string, string>();
|
||||
private static bool m_Dirty;
|
||||
|
||||
static VRCXStorage()
|
||||
{
|
||||
Instance = new VRCXStorage();
|
||||
}
|
||||
|
||||
public static void Load()
|
||||
{
|
||||
m_Lock.EnterWriteLock();
|
||||
|
||||
Reference in New Issue
Block a user