From 304437b834e8c87687f68333ae67a13ee1377a73 Mon Sep 17 00:00:00 2001 From: Dennis Kobert Date: Wed, 12 Jun 2019 21:47:51 +0200 Subject: Adjust Codestyle --- dsa/DSALib/DSA_Game/Save/Properties.cs | 33 +++++++++++---------------------- 1 file changed, 11 insertions(+), 22 deletions(-) (limited to 'dsa/DSALib/DSA_Game/Save/Properties.cs') diff --git a/dsa/DSALib/DSA_Game/Save/Properties.cs b/dsa/DSALib/DSA_Game/Save/Properties.cs index 2312af0..06628ed 100644 --- a/dsa/DSALib/DSA_Game/Save/Properties.cs +++ b/dsa/DSALib/DSA_Game/Save/Properties.cs @@ -6,33 +6,27 @@ using System.Linq; using DSALib.Auxiliary; using Newtonsoft.Json; -namespace DSALib.DSA_Game.Save -{ - public static class Properties - { +namespace DSALib.DSA_Game.Save { + public static class Properties { public static Dictionary objects; - static Properties() - { + static Properties() { objects = new Dictionary(); /*this.objects.Add("Sounds", new List()); this.objects.Add("CommandInfos", new List());*/ } - public static List CommandInfos - { + public static List CommandInfos { get => objects["CommandInfo"] as List; set => objects["CommandInfo"] = value; } // use Properties.Commandinfos to access the abstract Object array - public static void Deserialize(string path = @"Properties") - { + public static void Deserialize(string path = @"Properties") { var files = Directory.GetFiles(path, "*.json"); foreach (var file in files) - try - { + try { var name = file.Split('\\').Last().Split('.')[0].Replace('-', '.'); var data = File.ReadAllText(file); var type = Type.GetType(name); @@ -41,19 +35,15 @@ namespace DSALib.DSA_Game.Save var o = JsonConvert.DeserializeObject(data, type); objects.Add(name.Split('.').Last(), o); } - catch (Exception e) - { + catch (Exception e) { // ignored Console.WriteLine($"Laden von Save-File {file} fehlgeschlagen." + e); } } - public static void Serialize(string path = @"..\..\Properties\") - { - try - { - foreach (var o in objects) - { + public static void Serialize(string path = @"..\..\Properties\") { + try { + foreach (var o in objects) { var assembly = o.Value is IList list ? list[0]?.GetType().FullName : o.Value.GetType().FullName; @@ -64,8 +54,7 @@ namespace DSALib.DSA_Game.Save Formatting.Indented)); // Deserialize Data and create CommandInfo Struct } } - catch (Exception e) - { + catch (Exception e) { // ignored Console.WriteLine("Speichern von Save-File fehlgeschlagen." + e); } -- cgit v1.2.3-70-g09d2