diff --git a/Discord.cs b/Discord.cs index afd2b4cd..c1799a4e 100644 --- a/Discord.cs +++ b/Discord.cs @@ -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(() => diff --git a/LogWatcher.cs b/LogWatcher.cs index 342218a3..ec48d89a 100644 --- a/LogWatcher.cs +++ b/LogWatcher.cs @@ -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 m_GameLog = new List(); 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(() => diff --git a/MainForm.cs b/MainForm.cs index 89af721d..a38f1fa2 100644 --- a/MainForm.cs +++ b/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(); diff --git a/SQLite.cs b/SQLite.cs index dca32535..9632e054 100644 --- a/SQLite.cs +++ b/SQLite.cs @@ -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"); diff --git a/VRCX.cs b/VRCX.cs index d4e60741..1f446cc5 100644 --- a/VRCX.cs +++ b/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 diff --git a/VRCXStorage.cs b/VRCXStorage.cs index 6effc296..13d8c209 100644 --- a/VRCXStorage.cs +++ b/VRCXStorage.cs @@ -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 m_Storage = new Dictionary(); private static bool m_Dirty; + static VRCXStorage() + { + Instance = new VRCXStorage(); + } + public static void Load() { m_Lock.EnterWriteLock();