Added Support for Debug Logging

Updated a couple of variables for better memory use.
Added Support for ignoring specific streamers
Moved to using a SingletonFactory for Singlton Classes
No Longer Using MessageBox for disconnected message
Added better detection for disconnected to stop it poping with other problems
Added Window and menu option to open window to manage ignored streamers
This commit is contained in:
Martin Barker
2023-02-21 21:25:38 +00:00
parent 03b620ecec
commit 49ea2ba2a6
25 changed files with 548 additions and 208 deletions

View File

@@ -1,14 +1,12 @@
using System.Text.Json;
using TwitchDesktopNotifications.JsonStructure;
using System.IO;
using TwitchDesktopNotifications.Core;
namespace TwitchDesktopNotifications
{
internal class DataStore
public class DataStore : SingletonFactory<DataStore>, Singleton
{
private DataStore() { }
public static DataStore Instance { get; private set; }
private Store _store;
public JsonStructure.Store Store {
get {
@@ -25,15 +23,6 @@ namespace TwitchDesktopNotifications
public bool isLoaded { get; private set; }
public static DataStore GetInstance()
{
if(Instance == null)
{
Instance = new DataStore();
}
return Instance;
}
public void Save()
{
String FilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "TwitchNotify");
@@ -41,29 +30,30 @@ namespace TwitchDesktopNotifications
string fileContent = JsonSerializer.Serialize<JsonStructure.Store>(Store);
Console.WriteLine("I'm trying to save:");
Console.WriteLine(fileContent);
Console.WriteLine("to {0}", FilePath + "/" + FileName);
Directory.CreateDirectory(FilePath);
File.WriteAllText(FilePath + "/" + FileName, fileContent);
}
public void Load() {
String FilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "TwitchNotify");
String FileName = "store.json";
Directory.CreateDirectory(FilePath);
if(File.Exists(FilePath+"/"+ FileName)) {
string fileContent = File.ReadAllText(FilePath+"/"+ FileName);
Store = JsonSerializer.Deserialize<JsonStructure.Store>(fileContent);
}
else
if (!isLoaded)
{
Store = new JsonStructure.Store();
String FilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "TwitchNotify");
String FileName = "store.json";
Directory.CreateDirectory(FilePath);
if (File.Exists(FilePath + "/" + FileName))
{
string fileContent = File.ReadAllText(FilePath + "/" + FileName);
Store = JsonSerializer.Deserialize<JsonStructure.Store>(fileContent);
}
else
{
Store = new JsonStructure.Store();
}
isLoaded = true;
}
isLoaded= true;
}
}
}