mirror of
https://github.com/JKorf/CryptoExchange.Net
synced 2025-06-07 16:06:15 +00:00
Changed JsonConverterCtorAttribute to use type parameter instead of generic parameter to support .net framework
This commit is contained in:
parent
591c1dd405
commit
8260c2661d
@ -6,21 +6,25 @@ namespace CryptoExchange.Net.Converters.SystemTextJson
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Attribute for allowing specifying a JsonConverter with constructor parameters
|
/// Attribute for allowing specifying a JsonConverter with constructor parameters
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="T"></typeparam>
|
|
||||||
[AttributeUsage(AttributeTargets.Property)]
|
[AttributeUsage(AttributeTargets.Property)]
|
||||||
public class JsonConverterCtorAttribute<T> : JsonConverterAttribute where T : JsonConverter
|
public class JsonConverterCtorAttribute : JsonConverterAttribute
|
||||||
{
|
{
|
||||||
private readonly object[] _parameters;
|
private readonly object[] _parameters;
|
||||||
|
private readonly Type _type;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// ctor
|
/// ctor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public JsonConverterCtorAttribute(params object[] parameters) => _parameters = parameters;
|
public JsonConverterCtorAttribute(Type type, params object[] parameters)
|
||||||
|
{
|
||||||
|
_type = type;
|
||||||
|
_parameters = parameters;
|
||||||
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override JsonConverter CreateConverter(Type typeToConvert)
|
public override JsonConverter CreateConverter(Type typeToConvert)
|
||||||
{
|
{
|
||||||
return (T)Activator.CreateInstance(typeof(T), _parameters);
|
return (JsonConverter)Activator.CreateInstance(_type, _parameters);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user