diff --git a/SabreTools.Core/BaseFirstContractResolver.cs b/SabreTools.Core/BaseFirstContractResolver.cs deleted file mode 100644 index 40bd6293..00000000 --- a/SabreTools.Core/BaseFirstContractResolver.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; - -using Newtonsoft.Json; -using Newtonsoft.Json.Serialization; - -namespace SabreTools.Core -{ - // https://github.com/dotnet/runtime/issues/728 - public class BaseFirstContractResolver : DefaultContractResolver - { - public BaseFirstContractResolver() - { - NamingStrategy = new CamelCaseNamingStrategy(); - } - - protected override IList CreateProperties(Type type, MemberSerialization memberSerialization) - { - return base.CreateProperties(type, memberSerialization) - .OrderBy(p => BaseTypesAndSelf(p.DeclaringType).Count()).ToList(); - - IEnumerable BaseTypesAndSelf(Type t) - { - while (t != null) - { - yield return t; - t = t.BaseType; - } - } - } - } -} diff --git a/SabreTools.DatFiles/DatFiles/SabreJSON.cs b/SabreTools.DatFiles/DatFiles/SabreJSON.cs index cebf6e72..43ef459e 100644 --- a/SabreTools.DatFiles/DatFiles/SabreJSON.cs +++ b/SabreTools.DatFiles/DatFiles/SabreJSON.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.IO; +using System.Linq; using System.Text; using SabreTools.Core; @@ -8,6 +9,7 @@ using SabreTools.Core.Tools; using SabreTools.DatItems; using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using Newtonsoft.Json.Serialization; namespace SabreTools.DatFiles { @@ -520,5 +522,29 @@ namespace SabreTools.DatFiles jtw.Flush(); } + + // https://github.com/dotnet/runtime/issues/728 + private class BaseFirstContractResolver : DefaultContractResolver + { + public BaseFirstContractResolver() + { + NamingStrategy = new CamelCaseNamingStrategy(); + } + + protected override IList CreateProperties(Type type, MemberSerialization memberSerialization) + { + return base.CreateProperties(type, memberSerialization) + .OrderBy(p => BaseTypesAndSelf(p.DeclaringType).Count()).ToList(); + + IEnumerable BaseTypesAndSelf(Type t) + { + while (t != null) + { + yield return t; + t = t.BaseType; + } + } + } + } } }