From 380d9ec6048663b0e497e2437222d783236b864f Mon Sep 17 00:00:00 2001 From: TrueDoctor Date: Fri, 15 Jun 2018 09:58:24 +0200 Subject: Added Properties Class auto load last settings removed sound enumerable moved Sonds to properties moved Commands to properties --- DiscoBot/DSA_Game/Save/Properties.cs | 51 ++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 DiscoBot/DSA_Game/Save/Properties.cs (limited to 'DiscoBot/DSA_Game/Save') 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 CommandInfos { get; set; } + + public List Sounds { get; set; } + + public static Properties Deserialize(string path = @"..\..\Properties.json") + { + try + { + return JsonConvert.DeserializeObject(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 + } + } + } +} -- cgit v1.2.3-70-g09d2