From 8260c2661d2c64cae4e6d8e504c8e389690d0559 Mon Sep 17 00:00:00 2001 From: JKorf Date: Sun, 8 Dec 2024 10:12:39 +0100 Subject: [PATCH] Changed JsonConverterCtorAttribute to use type parameter instead of generic parameter to support .net framework --- .../SystemTextJson/JsonConverterCtorAttribute.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/CryptoExchange.Net/Converters/SystemTextJson/JsonConverterCtorAttribute.cs b/CryptoExchange.Net/Converters/SystemTextJson/JsonConverterCtorAttribute.cs index 48c42409..c831ea81 100644 --- a/CryptoExchange.Net/Converters/SystemTextJson/JsonConverterCtorAttribute.cs +++ b/CryptoExchange.Net/Converters/SystemTextJson/JsonConverterCtorAttribute.cs @@ -6,21 +6,25 @@ namespace CryptoExchange.Net.Converters.SystemTextJson /// /// Attribute for allowing specifying a JsonConverter with constructor parameters /// - /// [AttributeUsage(AttributeTargets.Property)] - public class JsonConverterCtorAttribute : JsonConverterAttribute where T : JsonConverter + public class JsonConverterCtorAttribute : JsonConverterAttribute { private readonly object[] _parameters; + private readonly Type _type; /// /// ctor /// - public JsonConverterCtorAttribute(params object[] parameters) => _parameters = parameters; + public JsonConverterCtorAttribute(Type type, params object[] parameters) + { + _type = type; + _parameters = parameters; + } /// public override JsonConverter CreateConverter(Type typeToConvert) { - return (T)Activator.CreateInstance(typeof(T), _parameters); + return (JsonConverter)Activator.CreateInstance(_type, _parameters); } }