summaryrefslogtreecommitdiff
path: root/DiscoBot/DSA_Game/Save/Properties.cs
diff options
context:
space:
mode:
Diffstat (limited to 'DiscoBot/DSA_Game/Save/Properties.cs')
-rw-r--r--DiscoBot/DSA_Game/Save/Properties.cs51
1 files changed, 51 insertions, 0 deletions
diff --git a/DiscoBot/DSA_Game/Save/Properties.cs b/DiscoBot/DSA_Game/Save/Properties.cs
new file mode 100644
index 0000000..5d99a56
--- /dev/null
+++ b/DiscoBot/DSA_Game/Save/Properties.cs
@@ -0,0 +1,51 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DiscoBot.DSA_Game.Save
+{
+ using System.IO;
+
+ using DiscoBot.Audio;
+ using DiscoBot.Auxiliary;
+ using DiscoBot.Commands;
+
+ using Newtonsoft.Json;
+
+ public class Properties
+ {
+ public List<CommandInfo> CommandInfos { get; set; }
+
+ public List<Sound> Sounds { get; set; }
+
+ public static Properties Deserialize(string path = @"..\..\Properties.json")
+ {
+ try
+ {
+ return JsonConvert.DeserializeObject<Properties>(File.ReadAllText(path)); // Deserialize Data and create CommandInfo Struct
+ }
+ catch (Exception e)
+ {
+ // ignored
+ return null;
+ }
+ }
+
+ public void Serialize(string path = @"..\..\Properties.json")
+ {/*
+ var stream = new StreamWriter(path); // Load properties file
+ var reader = new JsonTextWriter(stream); // create stream reader*/
+
+ try
+ {
+ File.WriteAllText(path, JsonConvert.SerializeObject(this, Formatting.Indented)); // Deserialize Data and create CommandInfo Struct
+ }
+ catch (Exception e)
+ {
+ // ignored
+ }
+ }
+ }
+}