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.cs17
1 files changed, 6 insertions, 11 deletions
diff --git a/DSACore/DSA_Game/Save/Properties.cs b/DSACore/DSA_Game/Save/Properties.cs
index 459a9c7..50bd8fa 100644
--- a/DSACore/DSA_Game/Save/Properties.cs
+++ b/DSACore/DSA_Game/Save/Properties.cs
@@ -39,17 +39,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 +55,6 @@ namespace DSACore.DSA_Game.Save
// ignored
Console.WriteLine($"Laden von Save-File {file} fehlgeschlagen." + e);
}
- }
}
public static void Serialize(string path = @"..\..\Properties\")
@@ -68,7 +63,7 @@ namespace DSACore.DSA_Game.Save
{
foreach (var o in objects)
{
- string assembly = o.Value is IList list
+ var assembly = o.Value is IList list
? ((IList) list)[0]?.GetType().FullName
: o.Value.GetType().FullName;