diff options
author | natrixaeria <janng@gmx.de> | 2019-05-19 17:40:59 +0200 |
---|---|---|
committer | natrixaeria <janng@gmx.de> | 2019-05-19 17:40:59 +0200 |
commit | 1509b5ef3d7e9e71d9294e234ec0e39f2d831998 (patch) | |
tree | 78300ffff230958101b422a4e6026925b287822f /DSACore/DSA_Game/Save/Properties.cs | |
parent | c3bb858bb54dc8c64bbd48054c2c58dc0073f09c (diff) | |
parent | c4d046858e0822b7c2c540ac2368b2c0e88e7a26 (diff) |
Merge branch 'scribble' of https://github.com/TrueDoctor/DiscoBot into scribble
Diffstat (limited to 'DSACore/DSA_Game/Save/Properties.cs')
-rw-r--r-- | DSACore/DSA_Game/Save/Properties.cs | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/DSACore/DSA_Game/Save/Properties.cs b/DSACore/DSA_Game/Save/Properties.cs index 459a9c7..7eba911 100644 --- a/DSACore/DSA_Game/Save/Properties.cs +++ b/DSACore/DSA_Game/Save/Properties.cs @@ -1,4 +1,5 @@ using System; +using System.Collections; using System.Collections.Generic; using System.IO; using System.Linq; @@ -8,10 +9,6 @@ using Newtonsoft.Json; namespace DSACore.DSA_Game.Save { - using System.Collections; - using System.IO; - using Newtonsoft.Json; - public static class Properties { public static Dictionary<string, object> objects; @@ -39,17 +36,13 @@ namespace DSACore.DSA_Game.Save { var files = Directory.GetFiles(path, "*.json"); - foreach (string file in files) - { + foreach (var file in files) try { - string name = file.Split('\\').Last().Split('.')[0].Replace('-', '.'); - string data = File.ReadAllText(file); - Type type = Type.GetType(name); - if (data.StartsWith("[")) - { - type = typeof(List<>).MakeGenericType(type); - } + var name = file.Split('\\').Last().Split('.')[0].Replace('-', '.'); + var data = File.ReadAllText(file); + var type = Type.GetType(name); + if (data.StartsWith("[")) type = typeof(List<>).MakeGenericType(type); var o = JsonConvert.DeserializeObject(data, type); objects.Add(name.Split('.').Last(), o); @@ -59,7 +52,6 @@ namespace DSACore.DSA_Game.Save // ignored Console.WriteLine($"Laden von Save-File {file} fehlgeschlagen." + e); } - } } public static void Serialize(string path = @"..\..\Properties\") @@ -68,8 +60,8 @@ namespace DSACore.DSA_Game.Save { foreach (var o in objects) { - string assembly = o.Value is IList list - ? ((IList) list)[0]?.GetType().FullName + var assembly = o.Value is IList list + ? list[0]?.GetType().FullName : o.Value.GetType().FullName; var name = path + assembly.Replace('.', '-') + ".json"; @@ -81,7 +73,7 @@ namespace DSACore.DSA_Game.Save catch (Exception e) { // ignored - Console.WriteLine($"Speichern von Save-File fehlgeschlagen." + e); + Console.WriteLine("Speichern von Save-File fehlgeschlagen." + e); } } } |