1
0
mirror of https://github.com/JKorf/CryptoExchange.Net.git synced 2026-08-19 20:33:03 +00:00

Feature/system.text.json (#192)

Initial support for System.Text.Json and some refactoring
This commit is contained in:
Jan Korf
2024-03-16 14:45:36 +01:00
committed by GitHub
parent 462c857bba
commit 2fb3442800
66 changed files with 2318 additions and 1095 deletions
@@ -1,5 +1,6 @@
using CryptoExchange.Net.Attributes;
using CryptoExchange.Net.Converters;
using CryptoExchange.Net.Converters.SystemTextJson;
using System;
using System.Collections.Generic;
using System.Globalization;
@@ -158,6 +159,17 @@ namespace CryptoExchange.Net.Objects
Add(key, EnumConverter.GetString(value)!);
}
/// <summary>
/// Add an enum value as the string value as mapped using the <see cref="MapAttribute" />
/// </summary>
/// <param name="key"></param>
/// <param name="value"></param>
public void AddEnumAsInt<T>(string key, T value)
{
var stringVal = EnumConverter.GetString(value);
Add(key, EnumConverter.GetString(int.Parse(stringVal))!);
}
/// <summary>
/// Add an enum value as the string value as mapped using the <see cref="MapAttribute" />. Not added if value is null
/// </summary>
@@ -168,5 +180,19 @@ namespace CryptoExchange.Net.Objects
if (value != null)
Add(key, EnumConverter.GetString(value));
}
/// <summary>
/// Add an enum value as the string value as mapped using the <see cref="MapAttribute" />. Not added if value is null
/// </summary>
/// <param name="key"></param>
/// <param name="value"></param>
public void AddOptionalEnumAsInt<T>(string key, T? value)
{
if (value != null)
{
var stringVal = EnumConverter.GetString(value);
Add(key, int.Parse(stringVal));
}
}
}
}
+3 -3
View File
@@ -31,8 +31,8 @@ namespace CryptoExchange.Net.Objects
/// </summary>
public class TraceLogger : ILogger
{
private string? _categoryName;
private LogLevel _logLevel;
private readonly string? _categoryName;
private readonly LogLevel _logLevel;
/// <summary>
/// ctor
@@ -46,7 +46,7 @@ namespace CryptoExchange.Net.Objects
}
/// <inheritdoc />
public IDisposable BeginScope<TState>(TState state) => null!;
public IDisposable? BeginScope<TState>(TState state) where TState : notnull => null!;
/// <inheritdoc />
public bool IsEnabled(LogLevel logLevel) => (int)logLevel < (int)_logLevel;