summaryrefslogtreecommitdiff
path: root/DSACore/DSA_Game/Save/Properties.cs
diff options
context:
space:
mode:
Diffstat (limited to 'DSACore/DSA_Game/Save/Properties.cs')
-rw-r--r--DSACore/DSA_Game/Save/Properties.cs26
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);
}
}
}