1
0
mirror of https://github.com/JKorf/CryptoExchange.Net synced 2025-06-10 09:26:22 +00:00

Merge pull request #6 from Zaliro/master

Properties can now be optional in response checking
This commit is contained in:
Jan Korf 2018-08-07 08:36:29 +02:00 committed by GitHub
commit ca7890cc58
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 0 deletions

View File

@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace CryptoExchange.Net.Attributes
{
public class JsonOptionalPropertyAttribute : Attribute
{
public JsonOptionalPropertyAttribute() { }
}
}

View File

@ -5,6 +5,7 @@ using System.Linq;
using System.Net;
using System.Reflection;
using System.Threading.Tasks;
using CryptoExchange.Net.Attributes;
using CryptoExchange.Net.Authentication;
using CryptoExchange.Net.Interfaces;
using CryptoExchange.Net.Logging;
@ -294,6 +295,12 @@ namespace CryptoExchange.Net
foreach (var prop in properties)
{
var propInfo = props.FirstOrDefault(p => p.Name == prop ||
((JsonPropertyAttribute)p.GetCustomAttributes(typeof(JsonPropertyAttribute), false).FirstOrDefault())?.PropertyName == prop);
var optional = propInfo.GetCustomAttributes(typeof(JsonOptionalPropertyAttribute), false).FirstOrDefault();
if (optional != null)
continue;
isDif = true;
log.Write(LogVerbosity.Warning, $"Didn't find key `{prop}` in returned data object of type `{type.Name}`");
}