mirror of
https://github.com/JKorf/CryptoExchange.Net
synced 2025-12-15 02:08:41 +00:00
wip
This commit is contained in:
parent
d03e4a53ef
commit
3a7ac88c53
@ -84,7 +84,7 @@ namespace CryptoExchange.Net.Converters.MessageParsing.DynamicConverters
|
|||||||
{
|
{
|
||||||
foreach(var item in _items)
|
foreach(var item in _items)
|
||||||
{
|
{
|
||||||
if (item.Field.SearchName == searchName)
|
if (item.Field.SearchName.Equals(searchName, StringComparison.Ordinal))
|
||||||
return item.Value;
|
return item.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -86,8 +86,8 @@ namespace CryptoExchange.Net.Converters.SystemTextJson
|
|||||||
{
|
{
|
||||||
var stringValue = reader.GetString();
|
var stringValue = reader.GetString();
|
||||||
if (string.IsNullOrWhiteSpace(stringValue)
|
if (string.IsNullOrWhiteSpace(stringValue)
|
||||||
|| stringValue == "-1"
|
|| stringValue!.Equals("-1", StringComparison.Ordinal)
|
||||||
|| stringValue == "0001-01-01T00:00:00Z"
|
|| stringValue!.Equals("0001-01-01T00:00:00Z", StringComparison.OrdinalIgnoreCase)
|
||||||
|| decimal.TryParse(stringValue, out var decVal) && decVal == 0)
|
|| decimal.TryParse(stringValue, out var decVal) && decVal == 0)
|
||||||
{
|
{
|
||||||
return default;
|
return default;
|
||||||
@ -127,7 +127,7 @@ namespace CryptoExchange.Net.Converters.SystemTextJson
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static DateTime ParseFromString(string stringValue, string? resolverName)
|
public static DateTime ParseFromString(string stringValue, string? resolverName)
|
||||||
{
|
{
|
||||||
if (stringValue!.Length == 12 && stringValue.StartsWith("202"))
|
if (stringValue!.Length == 12 && stringValue.StartsWith("202", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
// Parse 202303261200 format
|
// Parse 202303261200 format
|
||||||
if (!int.TryParse(stringValue.Substring(0, 4), out var year)
|
if (!int.TryParse(stringValue.Substring(0, 4), out var year)
|
||||||
|
|||||||
@ -48,7 +48,7 @@ namespace CryptoExchange.Net.Converters.SystemTextJson
|
|||||||
if (field is PropertyFieldReference propRef
|
if (field is PropertyFieldReference propRef
|
||||||
&& otherField is PropertyFieldReference otherPropRef)
|
&& otherField is PropertyFieldReference otherPropRef)
|
||||||
{
|
{
|
||||||
return field.Depth == otherPropRef.Depth && propRef.PropertyName == otherPropRef.PropertyName;
|
return field.Depth == otherPropRef.Depth && propRef.PropertyName.SequenceEqual(otherPropRef.PropertyName);
|
||||||
}
|
}
|
||||||
else if (field is ArrayFieldReference arrayRef
|
else if (field is ArrayFieldReference arrayRef
|
||||||
&& otherField is ArrayFieldReference otherArrayPropRef)
|
&& otherField is ArrayFieldReference otherArrayPropRef)
|
||||||
@ -62,11 +62,11 @@ namespace CryptoExchange.Net.Converters.SystemTextJson
|
|||||||
_overlappingFields = true;
|
_overlappingFields = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageEvalutorFieldReference? existing = null;
|
MessageEvalutorFieldReference? existingSameSearchField = null;
|
||||||
if (field is ArrayFieldReference arrayField)
|
if (field is ArrayFieldReference arrayField)
|
||||||
{
|
{
|
||||||
_hasArraySearches = true;
|
_hasArraySearches = true;
|
||||||
existing = _searchFields.SingleOrDefault(x =>
|
existingSameSearchField = _searchFields.SingleOrDefault(x =>
|
||||||
x.Field is ArrayFieldReference arrayFieldRef
|
x.Field is ArrayFieldReference arrayFieldRef
|
||||||
&& arrayFieldRef.ArrayIndex == arrayField.ArrayIndex
|
&& arrayFieldRef.ArrayIndex == arrayField.ArrayIndex
|
||||||
&& arrayFieldRef.Depth == arrayField.Depth
|
&& arrayFieldRef.Depth == arrayField.Depth
|
||||||
@ -74,39 +74,37 @@ namespace CryptoExchange.Net.Converters.SystemTextJson
|
|||||||
}
|
}
|
||||||
else if (field is PropertyFieldReference propField)
|
else if (field is PropertyFieldReference propField)
|
||||||
{
|
{
|
||||||
existing = _searchFields.SingleOrDefault(x =>
|
existingSameSearchField = _searchFields.SingleOrDefault(x =>
|
||||||
x.Field is PropertyFieldReference propFieldRef
|
x.Field is PropertyFieldReference propFieldRef
|
||||||
&& propFieldRef.PropertyName == propField.PropertyName
|
&& propFieldRef.PropertyName.SequenceEqual(propField.PropertyName)
|
||||||
&& propFieldRef.Depth == propField.Depth
|
&& propFieldRef.Depth == propField.Depth
|
||||||
&& (propFieldRef.Constraint == null && propFieldRef.Constraint == null));
|
&& (propFieldRef.Constraint == null && propFieldRef.Constraint == null));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (existing != null)
|
if (existingSameSearchField != null)
|
||||||
{
|
{
|
||||||
if (existing.SkipReading == true
|
if (existingSameSearchField.SkipReading == true
|
||||||
&& (evaluator.IdentifyMessageCallback != null
|
&& (evaluator.IdentifyMessageCallback != null
|
||||||
|| field.Constraint != null))
|
|| field.Constraint != null))
|
||||||
{
|
{
|
||||||
existing.SkipReading = false;
|
existingSameSearchField.SkipReading = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (evaluator.ForceIfFound)
|
if (evaluator.ForceIfFound)
|
||||||
{
|
{
|
||||||
if (evaluator.Fields.Length > 1 || existing.ForceEvaluator != null)
|
if (evaluator.Fields.Length > 1 || existingSameSearchField.ForceEvaluator != null)
|
||||||
throw new Exception("Invalid config");
|
throw new Exception("Invalid config");
|
||||||
|
|
||||||
existing.ForceEvaluator = evaluator;
|
existingSameSearchField.ForceEvaluator = evaluator;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
_searchFields.Add(new MessageEvalutorFieldReference
|
||||||
{
|
{
|
||||||
_searchFields.Add(new MessageEvalutorFieldReference
|
SkipReading = evaluator.IdentifyMessageCallback == null && field.Constraint == null,
|
||||||
{
|
ForceEvaluator = evaluator.ForceIfFound ? evaluator : null,
|
||||||
SkipReading = evaluator.IdentifyMessageCallback == null && field.Constraint == null,
|
Field = field
|
||||||
ForceEvaluator = evaluator.ForceIfFound ? evaluator : null,
|
});
|
||||||
Field = field
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (field.Depth > _maxSearchDepth)
|
if (field.Depth > _maxSearchDepth)
|
||||||
_maxSearchDepth = field.Depth;
|
_maxSearchDepth = field.Depth;
|
||||||
|
|||||||
@ -23,7 +23,8 @@ namespace CryptoExchange.Net.Objects
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Map the common name to an exchange name for an asset. If there is no alias the input name is returned
|
/// Map the common name to an exchange name for an asset. If there is no alias the input name is returned
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string CommonToExchangeName(string commonName) => !AutoConvertEnabled ? commonName : Aliases.FirstOrDefault(x => x.CommonAssetName == commonName)?.ExchangeAssetName ?? commonName;
|
public string CommonToExchangeName(string commonName) =>
|
||||||
|
!AutoConvertEnabled ? commonName : Aliases.FirstOrDefault(x => x.CommonAssetName.Equals(commonName, StringComparison.InvariantCulture))?.ExchangeAssetName ?? commonName;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Map the exchange name to a common name for an asset. If there is no alias the input name is returned
|
/// Map the exchange name to a common name for an asset. If there is no alias the input name is returned
|
||||||
@ -33,7 +34,7 @@ namespace CryptoExchange.Net.Objects
|
|||||||
if (!AutoConvertEnabled)
|
if (!AutoConvertEnabled)
|
||||||
return exchangeName;
|
return exchangeName;
|
||||||
|
|
||||||
var alias = Aliases.FirstOrDefault(x => x.ExchangeAssetName == exchangeName);
|
var alias = Aliases.FirstOrDefault(x => x.ExchangeAssetName.Equals(exchangeName, StringComparison.InvariantCulture));
|
||||||
if (alias == null || alias.Type == AliasType.OnlyToExchange)
|
if (alias == null || alias.Type == AliasType.OnlyToExchange)
|
||||||
return exchangeName;
|
return exchangeName;
|
||||||
|
|
||||||
|
|||||||
@ -21,7 +21,7 @@ namespace CryptoExchange.Net.RateLimiting.Filters
|
|||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public bool Passes(RateLimitItemType type, RequestDefinition definition, string host, string? apiKey)
|
public bool Passes(RateLimitItemType type, RequestDefinition definition, string host, string? apiKey)
|
||||||
=> host == _host;
|
=> host.Equals(_host, System.StringComparison.InvariantCulture);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Xml.Linq;
|
||||||
|
|
||||||
namespace CryptoExchange.Net.SharedApis
|
namespace CryptoExchange.Net.SharedApis
|
||||||
{
|
{
|
||||||
@ -39,8 +40,8 @@ namespace CryptoExchange.Net.SharedApis
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public bool HasValue(string exchange, string name, Type type)
|
public bool HasValue(string exchange, string name, Type type)
|
||||||
{
|
{
|
||||||
var val = _parameters.SingleOrDefault(x => x.Exchange == exchange && x.Name == name);
|
var val = _parameters.SingleOrDefault(x => x.Exchange.Equals(exchange, StringComparison.InvariantCulture) && x.Name.Equals(name, StringComparison.InvariantCulture));
|
||||||
val ??= _staticParameters.SingleOrDefault(x => x.Exchange == exchange && x.Name == name);
|
val ??= _staticParameters.SingleOrDefault(x => x.Exchange.Equals(exchange, StringComparison.InvariantCulture) && x.Name.Equals(name, StringComparison.InvariantCulture));
|
||||||
|
|
||||||
if (val == null)
|
if (val == null)
|
||||||
return false;
|
return false;
|
||||||
@ -71,7 +72,7 @@ namespace CryptoExchange.Net.SharedApis
|
|||||||
if (provided == true)
|
if (provided == true)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
var val = _staticParameters.SingleOrDefault(x => x.Exchange == exchange && x.Name == name);
|
var val = _staticParameters.SingleOrDefault(x => x.Exchange.Equals(exchange, StringComparison.InvariantCulture) && x.Name.Equals(name, StringComparison.InvariantCulture));
|
||||||
if (val == null)
|
if (val == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -95,7 +96,7 @@ namespace CryptoExchange.Net.SharedApis
|
|||||||
/// <param name="name">Parameter name</param>
|
/// <param name="name">Parameter name</param>
|
||||||
public T? GetValue<T>(string exchange, string name)
|
public T? GetValue<T>(string exchange, string name)
|
||||||
{
|
{
|
||||||
var val = _parameters.SingleOrDefault(x => x.Exchange == exchange && x.Name == name);
|
var val = _parameters.SingleOrDefault(x => x.Exchange.Equals(exchange, StringComparison.InvariantCulture) && x.Name.Equals(name, StringComparison.InvariantCulture));
|
||||||
if (val == null)
|
if (val == null)
|
||||||
return default;
|
return default;
|
||||||
|
|
||||||
@ -122,7 +123,7 @@ namespace CryptoExchange.Net.SharedApis
|
|||||||
T? value;
|
T? value;
|
||||||
if (exchangeParameters == null)
|
if (exchangeParameters == null)
|
||||||
{
|
{
|
||||||
var parameter = _staticParameters.SingleOrDefault(x => x.Exchange == exchange && x.Name == name);
|
var parameter = _staticParameters.SingleOrDefault(x => x.Exchange.Equals(exchange, StringComparison.InvariantCulture) && x.Name.Equals(name, StringComparison.InvariantCulture));
|
||||||
if (parameter == null)
|
if (parameter == null)
|
||||||
return default;
|
return default;
|
||||||
|
|
||||||
@ -155,7 +156,7 @@ namespace CryptoExchange.Net.SharedApis
|
|||||||
/// <param name="value">Parameter value</param>
|
/// <param name="value">Parameter value</param>
|
||||||
public static void SetStaticParameter(string exchange, string key, object value)
|
public static void SetStaticParameter(string exchange, string key, object value)
|
||||||
{
|
{
|
||||||
var existing = _staticParameters.SingleOrDefault(x => x.Exchange == exchange && x.Name == key);
|
var existing = _staticParameters.SingleOrDefault(x => x.Exchange.Equals(exchange, StringComparison.InvariantCulture) && x.Name.Equals(key, StringComparison.InvariantCulture));
|
||||||
if (existing != null)
|
if (existing != null)
|
||||||
{
|
{
|
||||||
existing.Value = value;
|
existing.Value = value;
|
||||||
|
|||||||
@ -121,7 +121,7 @@ namespace CryptoExchange.Net.Testing.Implementations
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task ReconnectAsync() => throw new NotImplementedException();
|
public Task ReconnectAsync() => Task.CompletedTask;
|
||||||
public void Dispose() { }
|
public void Dispose() { }
|
||||||
|
|
||||||
public void UpdateProxy(ApiProxy? proxy) => throw new NotImplementedException();
|
public void UpdateProxy(ApiProxy? proxy) => throw new NotImplementedException();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user