mirror of
https://github.com/JKorf/CryptoExchange.Net
synced 2025-06-08 16:36:15 +00:00
setted checking object parameter at Deserialize<T> to optional for backward compatibility, and added the same config field for preventing checking objects at Stream deserializing. added checking type for not null at CheckObject
This commit is contained in:
parent
3e3bf5329a
commit
1a73ecf89a
@ -36,6 +36,10 @@ namespace CryptoExchange.Net
|
|||||||
/// The auth provider
|
/// The auth provider
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected internal AuthenticationProvider? authProvider;
|
protected internal AuthenticationProvider? authProvider;
|
||||||
|
/// <summary>
|
||||||
|
/// Should check received objects
|
||||||
|
/// </summary>
|
||||||
|
public bool ShouldCheckObjects { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The last used id
|
/// The last used id
|
||||||
@ -73,6 +77,7 @@ namespace CryptoExchange.Net
|
|||||||
apiProxy = options.Proxy;
|
apiProxy = options.Proxy;
|
||||||
|
|
||||||
log.Write(LogVerbosity.Debug, $"Client configuration: {options}");
|
log.Write(LogVerbosity.Debug, $"Client configuration: {options}");
|
||||||
|
ShouldCheckObjects = options.ShouldCheckObjects;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -128,7 +133,7 @@ namespace CryptoExchange.Net
|
|||||||
/// <param name="checkObject">Whether or not the parsing should be checked for missing properties (will output data to the logging if log verbosity is Debug)</param>
|
/// <param name="checkObject">Whether or not the parsing should be checked for missing properties (will output data to the logging if log verbosity is Debug)</param>
|
||||||
/// <param name="serializer">A specific serializer to use</param>
|
/// <param name="serializer">A specific serializer to use</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
protected CallResult<T> Deserialize<T>(string data, bool checkObject = true, JsonSerializer? serializer = null)
|
protected CallResult<T> Deserialize<T>(string data, bool? checkObject = null, JsonSerializer? serializer = null)
|
||||||
{
|
{
|
||||||
var tokenResult = ValidateJson(data);
|
var tokenResult = ValidateJson(data);
|
||||||
if (!tokenResult)
|
if (!tokenResult)
|
||||||
@ -148,14 +153,14 @@ namespace CryptoExchange.Net
|
|||||||
/// <param name="checkObject">Whether or not the parsing should be checked for missing properties (will output data to the logging if log verbosity is Debug)</param>
|
/// <param name="checkObject">Whether or not the parsing should be checked for missing properties (will output data to the logging if log verbosity is Debug)</param>
|
||||||
/// <param name="serializer">A specific serializer to use</param>
|
/// <param name="serializer">A specific serializer to use</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
protected CallResult<T> Deserialize<T>(JToken obj, bool checkObject = true, JsonSerializer? serializer = null)
|
protected CallResult<T> Deserialize<T>(JToken obj, bool? checkObject = null, JsonSerializer? serializer = null)
|
||||||
{
|
{
|
||||||
if (serializer == null)
|
if (serializer == null)
|
||||||
serializer = defaultSerializer;
|
serializer = defaultSerializer;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (checkObject && log.Level == LogVerbosity.Debug)
|
if ((checkObject ?? ShouldCheckObjects)&& log.Level == LogVerbosity.Debug)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -256,6 +261,9 @@ namespace CryptoExchange.Net
|
|||||||
|
|
||||||
private void CheckObject(Type type, JObject obj)
|
private void CheckObject(Type type, JObject obj)
|
||||||
{
|
{
|
||||||
|
if (type == null)
|
||||||
|
return;
|
||||||
|
|
||||||
if (type.GetCustomAttribute<JsonConverterAttribute>(true) != null)
|
if (type.GetCustomAttribute<JsonConverterAttribute>(true) != null)
|
||||||
// If type has a custom JsonConverter we assume this will handle property mapping
|
// If type has a custom JsonConverter we assume this will handle property mapping
|
||||||
return;
|
return;
|
||||||
|
@ -84,8 +84,10 @@ namespace CryptoExchange.Net.Objects
|
|||||||
/// The api credentials
|
/// The api credentials
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ApiCredentials? ApiCredentials { get; set; }
|
public ApiCredentials? ApiCredentials { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// ShoouldCheckObjects
|
||||||
|
/// </summary>
|
||||||
|
public bool ShouldCheckObjects { get; set; } = true;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Proxy to use
|
/// Proxy to use
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user