summaryrefslogtreecommitdiff
path: root/DiscoBot/DSA_Game/Save
diff options
context:
space:
mode:
authorTrueDoctor <d-kobert@web.de>2018-06-15 09:58:24 +0200
committerTrueDoctor <d-kobert@web.de>2018-06-15 09:58:24 +0200
commit380d9ec6048663b0e497e2437222d783236b864f (patch)
tree635fd93e6902c696abe31526da1fc15db7f2d516 /DiscoBot/DSA_Game/Save
parentc00b3bbf39ae2756aecceaa54b3a87a0e3955a9e (diff)
Added Properties Class
auto load last settings removed sound enumerable moved Sonds to properties moved Commands to properties
Diffstat (limited to 'DiscoBot/DSA_Game/Save')
-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
+ }
+ }
+ }
+}