diff --git a/CryptoExchange.Net/BaseClient.cs b/CryptoExchange.Net/BaseClient.cs index b01e1a1..8e73049 100644 --- a/CryptoExchange.Net/BaseClient.cs +++ b/CryptoExchange.Net/BaseClient.cs @@ -36,6 +36,10 @@ namespace CryptoExchange.Net /// The auth provider /// protected internal AuthenticationProvider? authProvider; + /// + /// Should check received objects + /// + public bool ShouldCheckObjects { get; set; } /// /// The last used id @@ -73,6 +77,7 @@ namespace CryptoExchange.Net apiProxy = options.Proxy; log.Write(LogVerbosity.Debug, $"Client configuration: {options}"); + ShouldCheckObjects = options.ShouldCheckObjects; } /// @@ -128,7 +133,7 @@ namespace CryptoExchange.Net /// Whether or not the parsing should be checked for missing properties (will output data to the logging if log verbosity is Debug) /// A specific serializer to use /// - protected CallResult Deserialize(string data, bool checkObject = true, JsonSerializer? serializer = null) + protected CallResult Deserialize(string data, bool? checkObject = null, JsonSerializer? serializer = null) { var tokenResult = ValidateJson(data); if (!tokenResult) @@ -148,14 +153,14 @@ namespace CryptoExchange.Net /// Whether or not the parsing should be checked for missing properties (will output data to the logging if log verbosity is Debug) /// A specific serializer to use /// - protected CallResult Deserialize(JToken obj, bool checkObject = true, JsonSerializer? serializer = null) + protected CallResult Deserialize(JToken obj, bool? checkObject = null, JsonSerializer? serializer = null) { if (serializer == null) serializer = defaultSerializer; try { - if (checkObject && log.Level == LogVerbosity.Debug) + if ((checkObject ?? ShouldCheckObjects)&& log.Level == LogVerbosity.Debug) { try { @@ -256,6 +261,9 @@ namespace CryptoExchange.Net private void CheckObject(Type type, JObject obj) { + if (type == null) + return; + if (type.GetCustomAttribute(true) != null) // If type has a custom JsonConverter we assume this will handle property mapping return; diff --git a/CryptoExchange.Net/Objects/Options.cs b/CryptoExchange.Net/Objects/Options.cs index 577de1e..80354a7 100644 --- a/CryptoExchange.Net/Objects/Options.cs +++ b/CryptoExchange.Net/Objects/Options.cs @@ -84,8 +84,10 @@ namespace CryptoExchange.Net.Objects /// The api credentials /// public ApiCredentials? ApiCredentials { get; set; } - - + /// + /// ShoouldCheckObjects + /// + public bool ShouldCheckObjects { get; set; } = true; /// /// Proxy to use ///