From 01027e4f35b08d03e22f34ca1baf835d72ab1539 Mon Sep 17 00:00:00 2001 From: JustArchi Date: Sun, 19 Jul 2020 00:50:19 +0200 Subject: [PATCH] How about NOT reinventing the wheel? --- ArchiSteamFarm/IPC/Startup.cs | 4 +- ArchiSteamFarm/Json/VersionStringConverter.cs | 51 ------------------- 2 files changed, 2 insertions(+), 53 deletions(-) delete mode 100644 ArchiSteamFarm/Json/VersionStringConverter.cs diff --git a/ArchiSteamFarm/IPC/Startup.cs b/ArchiSteamFarm/IPC/Startup.cs index 65e9576a5..c7d9b81af 100644 --- a/ArchiSteamFarm/IPC/Startup.cs +++ b/ArchiSteamFarm/IPC/Startup.cs @@ -38,7 +38,7 @@ using Newtonsoft.Json; using Newtonsoft.Json.Serialization; #if NETFRAMEWORK -using ArchiSteamFarm.Json; +using Newtonsoft.Json.Converters; #endif namespace ArchiSteamFarm.IPC { @@ -245,7 +245,7 @@ namespace ArchiSteamFarm.IPC { #if NETFRAMEWORK // .NET Framework serializes Version as object by default, serialize it as string just like .NET Core - options.SerializerSettings.Converters.Add(new VersionStringConverter()); + options.SerializerSettings.Converters.Add(new VersionConverter()); #endif } ); diff --git a/ArchiSteamFarm/Json/VersionStringConverter.cs b/ArchiSteamFarm/Json/VersionStringConverter.cs deleted file mode 100644 index 6c483bf71..000000000 --- a/ArchiSteamFarm/Json/VersionStringConverter.cs +++ /dev/null @@ -1,51 +0,0 @@ -// _ _ _ ____ _ _____ -// / \ _ __ ___ | |__ (_)/ ___| | |_ ___ __ _ _ __ ___ | ___|__ _ _ __ _ __ ___ -// / _ \ | '__|/ __|| '_ \ | |\___ \ | __|/ _ \ / _` || '_ ` _ \ | |_ / _` || '__|| '_ ` _ \ -// / ___ \ | | | (__ | | | || | ___) || |_| __/| (_| || | | | | || _|| (_| || | | | | | | | -// /_/ \_\|_| \___||_| |_||_||____/ \__|\___| \__,_||_| |_| |_||_| \__,_||_| |_| |_| |_| -// | -// Copyright 2015-2020 Ɓukasz "JustArchi" Domeradzki -// Contact: JustArchi@JustArchi.net -// | -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// | -// http://www.apache.org/licenses/LICENSE-2.0 -// | -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if NETFRAMEWORK -using System; -using System.Diagnostics.CodeAnalysis; -using JetBrains.Annotations; -using Newtonsoft.Json; - -namespace ArchiSteamFarm.Json { - internal sealed class VersionStringConverter : JsonConverter { - [SuppressMessage("ReSharper", "AnnotationRedundancyInHierarchy")] - public override Version ReadJson([NotNull] JsonReader reader, Type objectType, Version existingValue, bool hasExistingValue, JsonSerializer serializer) { - if (reader == null) { - throw new ArgumentNullException(nameof(reader)); - } - - string versionText = reader.Value as string; - - return !string.IsNullOrEmpty(versionText) ? new Version(versionText) : null; - } - - [SuppressMessage("ReSharper", "AnnotationRedundancyInHierarchy")] - public override void WriteJson([NotNull] JsonWriter writer, Version value, JsonSerializer serializer) { - if (writer == null) { - throw new ArgumentNullException(nameof(writer)); - } - - writer.WriteValue(value?.ToString()); - } - } -} -#endif