Merge pull request #709 from erri120/json-fixes

Smaller JSON fixes
This commit is contained in:
Timothy Baldridge 2020-04-12 14:23:32 -06:00 committed by GitHub
commit c99dd71757
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,11 +1,9 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using Wabbajack.Common.Serialization.Json;
@ -19,7 +17,7 @@ namespace Wabbajack.Common
{
new HashJsonConverter(),
new RelativePathConverter(),
new AbolutePathConverter(),
new AbsolutePathConverter(),
new HashRelativePathConverter(),
new FullPathConverter(),
new GameConverter(),
@ -33,7 +31,7 @@ namespace Wabbajack.Common
Converters = Converters};
public static JsonSerializerSettings GenericJsonSettings =>
new JsonSerializerSettings { };
new JsonSerializerSettings();
public static void ToJson<T>(this T obj, string filename)
@ -112,7 +110,7 @@ namespace Wabbajack.Common
}
}
private class AbolutePathConverter : JsonConverter<AbsolutePath>
private class AbsolutePathConverter : JsonConverter<AbsolutePath>
{
public override void WriteJson(JsonWriter writer, AbsolutePath value, JsonSerializer serializer)
{
@ -241,11 +239,11 @@ namespace Wabbajack.Common
{
private static Dictionary<string, Type> _nameToType = new Dictionary<string, Type>();
private static Dictionary<Type, string> _typeToName = new Dictionary<Type, string>();
private static bool _inited = false;
private static bool _init;
public JsonNameSerializationBinder()
{
if (_inited)
if (_init)
return;
var customDisplayNameTypes =
@ -275,7 +273,7 @@ namespace Wabbajack.Common
_typeToName = _nameToType.ToDictionary(
t => t.Value,
t => t.Key);
_inited = true;
_init = true;
}