1
0
mirror of https://github.com/JKorf/CryptoExchange.Net synced 2025-09-06 23:51:46 +00:00
This commit is contained in:
JKorf 2025-08-24 21:58:52 +02:00
parent d0284c62c0
commit 4c953e2c87
354 changed files with 23357 additions and 23680 deletions

View File

@ -5,6 +5,10 @@
<IsPackable>false</IsPackable> <IsPackable>false</IsPackable>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<None Include="..\CryptoExchange.Net\.editorconfig" Link=".editorconfig" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1"></PackageReference> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1"></PackageReference>
<PackageReference Include="Moq" Version="4.20.72" /> <PackageReference Include="Moq" Version="4.20.72" />

View File

@ -0,0 +1,182 @@
root = true
[*]
# Indentation and spacing
indent_style = space
indent_size = 4
trim_trailing_whitespace = true
charset = utf-8
insert_final_newline = true
# ReSharper code style properties
resharper_csharp_keep_existing_embedded_arrangement = false
resharper_csharp_place_accessorholder_attribute_on_same_line = false
resharper_csharp_wrap_after_declaration_lpar = true
resharper_csharp_wrap_parameters_style = chop_if_long
resharper_csharp_blank_lines_around_single_line_auto_property = 1
resharper_csharp_keep_blank_lines_in_declarations = 1
resharper_trailing_comma_in_multiline_lists = true
[*.cs]
indent_size = 4
# Code style conventions
dotnet_style_predefined_type_for_member_access = true:suggestion
dotnet_style_collection_initializer = true:suggestion
dotnet_style_object_initializer = true:suggestion
csharp_style_var_when_type_is_apparent = true:suggestion
csharp_style_expression_bodied_methods = true:suggestion
csharp_style_namespace_declarations = file_scoped:warning
dotnet_style_coalesce_expression = true:suggestion
dotnet_style_null_propagation = true:suggestion
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
dotnet_style_prefer_simplified_boolean_expressions = true:suggestion
csharp_prefer_braces = when_multiline:warning
# Analyzer preferences
dotnet_diagnostic.CA2007.severity = warning # Call ConfigureAwait on the awaited Task.
dotnet_code_quality.CA2007.exclude_async_void_methods = true
dotnet_code_quality.CA2007.output_kind = DynamicallyLinkedLibrary
dotnet_diagnostic.CA1000.severity = none # Do not declare static members on generic types
dotnet_diagnostic.CA1051.severity = none # Do not declare visible instance fields
dotnet_diagnostic.CA1510.severity = none # Use ArgumentNullException throw helper
dotnet_diagnostic.CA1720.severity = none # Identifiers should not contain type names
dotnet_diagnostic.CA1716.severity = none # Identifiers should not match keywords
dotnet_diagnostic.CA1835.severity = none # Use ArgumentNullException throw helper
dotnet_diagnostic.CA1846.severity = none # Prefer AsSpan over Substring
dotnet_diagnostic.CA1848.severity = none # Use the LoggerMessage delegates
dotnet_diagnostic.CA1850.severity = none # Prefer static HashData method over ComputeHash
dotnet_diagnostic.CA1866.severity = none # Use 'string.Method(char)' instead of 'string.Method(string)' for string with single char
dotnet_diagnostic.CA2201.severity = none # Do not raise reserved exception types
dotnet_diagnostic.CA2208.severity = none # Do not raise reserved exception types
dotnet_diagnostic.IDE0005.severity = warning # Using directive is unnecessary
[*.xml]
ij_xml_space_inside_empty_tag = true
[*.cs]
#### Naming styles ####
# Naming rules
dotnet_naming_rule.interface_should_be_begins_with_i.severity = warning
dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface
dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i
dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = warning
dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members
dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case
dotnet_naming_rule.private_or_internal_field_should_be_fields_start_with__.severity = warning
dotnet_naming_rule.private_or_internal_field_should_be_fields_start_with__.symbols = private_or_internal_field
dotnet_naming_rule.private_or_internal_field_should_be_fields_start_with__.style = fields_start_with__
# Symbol specifications
dotnet_naming_symbols.interface.applicable_kinds = interface
dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.interface.required_modifiers =
dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method
dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.non_field_members.required_modifiers =
dotnet_naming_symbols.private_or_internal_field.applicable_kinds = field
dotnet_naming_symbols.private_or_internal_field.applicable_accessibilities = internal, private, private_protected
dotnet_naming_symbols.private_or_internal_field.required_modifiers =
# Naming styles
dotnet_naming_style.begins_with_i.required_prefix = I
dotnet_naming_style.begins_with_i.required_suffix =
dotnet_naming_style.begins_with_i.word_separator =
dotnet_naming_style.begins_with_i.capitalization = pascal_case
dotnet_naming_style.pascal_case.required_prefix =
dotnet_naming_style.pascal_case.required_suffix =
dotnet_naming_style.pascal_case.word_separator =
dotnet_naming_style.pascal_case.capitalization = pascal_case
dotnet_naming_style.fields_start_with__.required_prefix = _
dotnet_naming_style.fields_start_with__.required_suffix =
dotnet_naming_style.fields_start_with__.word_separator =
dotnet_naming_style.fields_start_with__.capitalization = camel_case
csharp_indent_labels = one_less_than_current
csharp_using_directive_placement = outside_namespace:suggestion
csharp_prefer_simple_using_statement = true:suggestion
csharp_style_prefer_method_group_conversion = true:silent
csharp_style_prefer_top_level_statements = true:silent
csharp_style_prefer_primary_constructors = true:suggestion
csharp_prefer_system_threading_lock = true:suggestion
csharp_style_expression_bodied_constructors = false:silent
csharp_style_expression_bodied_operators = false:silent
csharp_style_expression_bodied_properties = true:suggestion
csharp_style_expression_bodied_indexers = true:suggestion
csharp_style_expression_bodied_accessors = true:suggestion
csharp_style_expression_bodied_lambdas = true:silent
csharp_style_expression_bodied_local_functions = true:silent
[*.vb]
#### Naming styles ####
# Naming rules
dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion
dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface
dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i
dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members
dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case
# Symbol specifications
dotnet_naming_symbols.interface.applicable_kinds = interface
dotnet_naming_symbols.interface.applicable_accessibilities = public, friend, private, protected, protected_friend, private_protected
dotnet_naming_symbols.interface.required_modifiers =
dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method
dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, friend, private, protected, protected_friend, private_protected
dotnet_naming_symbols.non_field_members.required_modifiers =
# Naming styles
dotnet_naming_style.begins_with_i.required_prefix = I
dotnet_naming_style.begins_with_i.required_suffix =
dotnet_naming_style.begins_with_i.word_separator =
dotnet_naming_style.begins_with_i.capitalization = pascal_case
dotnet_naming_style.pascal_case.required_prefix =
dotnet_naming_style.pascal_case.required_suffix =
dotnet_naming_style.pascal_case.word_separator =
dotnet_naming_style.pascal_case.capitalization = pascal_case
[*.{cs,vb}]
#### Naming styles ####
# Naming rules
dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.types_should_be_pascal_case.symbols = types
dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case
# Symbol specifications
dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum
dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.types.required_modifiers =
# Naming styles
dotnet_naming_style.pascal_case.required_prefix =
dotnet_naming_style.pascal_case.required_suffix =
dotnet_naming_style.pascal_case.word_separator =
dotnet_naming_style.pascal_case.capitalization = pascal_case
dotnet_style_operator_placement_when_wrapping = beginning_of_line
tab_width = 4
end_of_line = crlf
dotnet_style_coalesce_expression = true:suggestion
dotnet_style_null_propagation = true:suggestion
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion

View File

@ -1,6 +1,5 @@
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("CryptoExchange.Net.UnitTests")] [assembly: System.Runtime.CompilerServices.InternalsVisibleTo("CryptoExchange.Net.UnitTests")]
namespace System.Runtime.CompilerServices;
namespace System.Runtime.CompilerServices
{
internal static class IsExternalInit { } internal static class IsExternalInit { }
}

View File

@ -1,7 +1,7 @@
using System; using System;
namespace CryptoExchange.Net.Attributes;
namespace CryptoExchange.Net.Attributes
{
/// <summary> /// <summary>
/// Used for conversion in ArrayConverter /// Used for conversion in ArrayConverter
/// </summary> /// </summary>
@ -9,4 +9,3 @@ namespace CryptoExchange.Net.Attributes
public class JsonConversionAttribute: Attribute public class JsonConversionAttribute: Attribute
{ {
} }
}

View File

@ -1,7 +1,7 @@
using System; using System;
namespace CryptoExchange.Net.Attributes;
namespace CryptoExchange.Net.Attributes
{
/// <summary> /// <summary>
/// Map a enum entry to string values /// Map a enum entry to string values
/// </summary> /// </summary>
@ -22,4 +22,3 @@ namespace CryptoExchange.Net.Attributes
Values = maps; Values = maps;
} }
} }
}

View File

@ -1,10 +1,7 @@
using System; using System;
using System.IO;
using CryptoExchange.Net.Converters.SystemTextJson; namespace CryptoExchange.Net.Authentication;
using CryptoExchange.Net.Converters.MessageParsing;
namespace CryptoExchange.Net.Authentication
{
/// <summary> /// <summary>
/// Api credentials, used to sign requests accessing private endpoints /// Api credentials, used to sign requests accessing private endpoints
/// </summary> /// </summary>
@ -57,4 +54,3 @@ namespace CryptoExchange.Net.Authentication
return new ApiCredentials(Key, Secret, Pass, CredentialType); return new ApiCredentials(Key, Secret, Pass, CredentialType);
} }
} }
}

View File

@ -1,5 +1,5 @@
namespace CryptoExchange.Net.Authentication namespace CryptoExchange.Net.Authentication;
{
/// <summary> /// <summary>
/// Credentials type /// Credentials type
/// </summary> /// </summary>
@ -18,4 +18,3 @@
/// </summary> /// </summary>
RsaPem RsaPem
} }
}

View File

@ -1,16 +1,15 @@
using CryptoExchange.Net.Clients; using CryptoExchange.Net.Clients;
using CryptoExchange.Net.Converters.SystemTextJson; using CryptoExchange.Net.Converters.SystemTextJson;
using CryptoExchange.Net.Interfaces; using CryptoExchange.Net.Interfaces;
using CryptoExchange.Net.Objects; using CryptoExchange.Net.Objects;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.Net.Http;
using System.Security.Cryptography; using System.Security.Cryptography;
using System.Text; using System.Text;
namespace CryptoExchange.Net.Authentication namespace CryptoExchange.Net.Authentication;
{
/// <summary> /// <summary>
/// Base class for authentication providers /// Base class for authentication providers
/// </summary> /// </summary>
@ -209,7 +208,9 @@ namespace CryptoExchange.Net.Authentication
/// <returns></returns> /// <returns></returns>
protected static string SignMD5(string data, SignOutputType? outputType = null) protected static string SignMD5(string data, SignOutputType? outputType = null)
{ {
#pragma warning disable CA5351
using var encryptor = MD5.Create(); using var encryptor = MD5.Create();
#pragma warning restore CA5351
var resultBytes = encryptor.ComputeHash(Encoding.UTF8.GetBytes(data)); var resultBytes = encryptor.ComputeHash(Encoding.UTF8.GetBytes(data));
return outputType == SignOutputType.Base64 ? BytesToBase64String(resultBytes) : BytesToHexString(resultBytes); return outputType == SignOutputType.Base64 ? BytesToBase64String(resultBytes) : BytesToHexString(resultBytes);
} }
@ -222,7 +223,9 @@ namespace CryptoExchange.Net.Authentication
/// <returns></returns> /// <returns></returns>
protected static string SignMD5(byte[] data, SignOutputType? outputType = null) protected static string SignMD5(byte[] data, SignOutputType? outputType = null)
{ {
#pragma warning disable CA5351
using var encryptor = MD5.Create(); using var encryptor = MD5.Create();
#pragma warning restore CA5351
var resultBytes = encryptor.ComputeHash(data); var resultBytes = encryptor.ComputeHash(data);
return outputType == SignOutputType.Base64 ? BytesToBase64String(resultBytes) : BytesToHexString(resultBytes); return outputType == SignOutputType.Base64 ? BytesToBase64String(resultBytes) : BytesToHexString(resultBytes);
} }
@ -234,7 +237,9 @@ namespace CryptoExchange.Net.Authentication
/// <returns></returns> /// <returns></returns>
protected static byte[] SignMD5Bytes(string data) protected static byte[] SignMD5Bytes(string data)
{ {
#pragma warning disable CA5351
using var encryptor = MD5.Create(); using var encryptor = MD5.Create();
#pragma warning restore CA5351
return encryptor.ComputeHash(Encoding.UTF8.GetBytes(data)); return encryptor.ComputeHash(Encoding.UTF8.GetBytes(data));
} }
@ -470,4 +475,3 @@ namespace CryptoExchange.Net.Authentication
{ {
} }
} }
}

View File

@ -1,5 +1,5 @@
namespace CryptoExchange.Net.Authentication namespace CryptoExchange.Net.Authentication;
{
/// <summary> /// <summary>
/// Output string type /// Output string type
/// </summary> /// </summary>
@ -14,4 +14,3 @@
/// </summary> /// </summary>
Base64 Base64
} }
}

View File

@ -1,9 +1,9 @@
using System; using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Linq; using System.Linq;
namespace CryptoExchange.Net.Caching namespace CryptoExchange.Net.Caching;
{
internal class MemoryCache internal class MemoryCache
{ {
private readonly ConcurrentDictionary<string, CacheItem> _cache = new ConcurrentDictionary<string, CacheItem>(); private readonly ConcurrentDictionary<string, CacheItem> _cache = new ConcurrentDictionary<string, CacheItem>();
@ -50,4 +50,3 @@ namespace CryptoExchange.Net.Caching
} }
} }
} }
}

View File

@ -1,15 +1,13 @@
using System; using System;
using System.Collections.Generic;
using CryptoExchange.Net.Authentication; using CryptoExchange.Net.Authentication;
using CryptoExchange.Net.Interfaces; using CryptoExchange.Net.Interfaces;
using CryptoExchange.Net.Objects;
using CryptoExchange.Net.Objects.Errors; using CryptoExchange.Net.Objects.Errors;
using CryptoExchange.Net.Objects.Options; using CryptoExchange.Net.Objects.Options;
using CryptoExchange.Net.SharedApis; using CryptoExchange.Net.SharedApis;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
namespace CryptoExchange.Net.Clients namespace CryptoExchange.Net.Clients;
{
/// <summary> /// <summary>
/// Base API for all API clients /// Base API for all API clients
/// </summary> /// </summary>
@ -131,4 +129,3 @@ namespace CryptoExchange.Net.Clients
_disposing = true; _disposing = true;
} }
} }
}

View File

@ -1,12 +1,11 @@
using CryptoExchange.Net.Authentication; using CryptoExchange.Net.Authentication;
using CryptoExchange.Net.Objects.Options; using CryptoExchange.Net.Objects.Options;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace CryptoExchange.Net.Clients namespace CryptoExchange.Net.Clients;
{
/// <summary> /// <summary>
/// The base for all clients, websocket client and rest client /// The base for all clients, websocket client and rest client
/// </summary> /// </summary>
@ -80,7 +79,7 @@ namespace CryptoExchange.Net.Clients
throw new ArgumentNullException(nameof(options)); throw new ArgumentNullException(nameof(options));
ClientOptions = options; ClientOptions = options;
_logger.Log(LogLevel.Trace, $"Client configuration: {options}, CryptoExchange.Net: v{CryptoExchangeLibVersion}, {Exchange}.Net: v{ExchangeLibVersion}"); _logger.Log(LogLevel.Trace, "Client configuration: {Options}, CryptoExchange.Net: v{CryptoExchangeVersion}, {Exchange}.Net: v{ExchangeVersion}", options, CryptoExchangeLibVersion, Exchange, ExchangeLibVersion);
} }
/// <summary> /// <summary>
@ -102,7 +101,7 @@ namespace CryptoExchange.Net.Clients
if (ClientOptions == null) if (ClientOptions == null)
throw new InvalidOperationException("Client should have called Initialize before adding API clients"); throw new InvalidOperationException("Client should have called Initialize before adding API clients");
_logger.Log(LogLevel.Trace, $" {apiClient.GetType().Name}, base address: {apiClient.BaseAddress}"); _logger.Log(LogLevel.Trace, " {ApiClient}, base address: {BaseAddress}", apiClient.GetType().Name, apiClient.BaseAddress);
ApiClients.Add(apiClient); ApiClients.Add(apiClient);
return apiClient; return apiClient;
} }
@ -127,4 +126,3 @@ namespace CryptoExchange.Net.Clients
client.Dispose(); client.Dispose();
} }
} }
}

View File

@ -3,8 +3,8 @@ using CryptoExchange.Net.Interfaces;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions; using Microsoft.Extensions.Logging.Abstractions;
namespace CryptoExchange.Net.Clients namespace CryptoExchange.Net.Clients;
{
/// <summary> /// <summary>
/// Base rest client /// Base rest client
/// </summary> /// </summary>
@ -23,4 +23,3 @@ namespace CryptoExchange.Net.Clients
_logger = loggerFactory?.CreateLogger(name + ".RestClient") ?? NullLoggerFactory.Instance.CreateLogger(name); _logger = loggerFactory?.CreateLogger(name + ".RestClient") ?? NullLoggerFactory.Instance.CreateLogger(name);
} }
} }
}

View File

@ -1,17 +1,16 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Xml.Linq;
using CryptoExchange.Net.Interfaces; using CryptoExchange.Net.Interfaces;
using CryptoExchange.Net.Logging.Extensions; using CryptoExchange.Net.Logging.Extensions;
using CryptoExchange.Net.Objects.Sockets; using CryptoExchange.Net.Objects.Sockets;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions; using Microsoft.Extensions.Logging.Abstractions;
namespace CryptoExchange.Net.Clients namespace CryptoExchange.Net.Clients;
{
/// <summary> /// <summary>
/// Base for socket client implementations /// Base for socket client implementations
/// </summary> /// </summary>
@ -129,4 +128,3 @@ namespace CryptoExchange.Net.Clients
return result; return result;
} }
} }
}

View File

@ -1,9 +1,9 @@
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace CryptoExchange.Net.Clients namespace CryptoExchange.Net.Clients;
{
/// <summary> /// <summary>
/// Base crypto client /// Base crypto client
/// </summary> /// </summary>
@ -64,4 +64,3 @@ namespace CryptoExchange.Net.Clients
_serviceCache.Clear(); _serviceCache.Clear();
} }
} }
}

View File

@ -1,11 +1,8 @@
using CryptoExchange.Net.Interfaces; using CryptoExchange.Net.Interfaces;
using Microsoft.Extensions.DependencyInjection;
using System; using System;
using System.Collections.Generic;
using System.Linq;
namespace CryptoExchange.Net.Clients namespace CryptoExchange.Net.Clients;
{
/// <inheritdoc /> /// <inheritdoc />
public class CryptoRestClient : CryptoBaseClient, ICryptoRestClient public class CryptoRestClient : CryptoBaseClient, ICryptoRestClient
{ {
@ -24,4 +21,3 @@ namespace CryptoExchange.Net.Clients
{ {
} }
} }
}

View File

@ -1,8 +1,8 @@
using CryptoExchange.Net.Interfaces; using CryptoExchange.Net.Interfaces;
using System; using System;
namespace CryptoExchange.Net.Clients namespace CryptoExchange.Net.Clients;
{
/// <inheritdoc /> /// <inheritdoc />
public class CryptoSocketClient : CryptoBaseClient, ICryptoSocketClient public class CryptoSocketClient : CryptoBaseClient, ICryptoSocketClient
{ {
@ -21,4 +21,3 @@ namespace CryptoExchange.Net.Clients
{ {
} }
} }
}

View File

@ -18,8 +18,8 @@ using CryptoExchange.Net.RateLimiting.Interfaces;
using CryptoExchange.Net.Requests; using CryptoExchange.Net.Requests;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
namespace CryptoExchange.Net.Clients namespace CryptoExchange.Net.Clients;
{
/// <summary> /// <summary>
/// Base rest API client for interacting with a REST API /// Base rest API client for interacting with a REST API
/// </summary> /// </summary>
@ -722,4 +722,3 @@ namespace CryptoExchange.Net.Clients
&& definition.Method == HttpMethod.Get && definition.Method == HttpMethod.Get
&& !definition.PreventCaching; && !definition.PreventCaching;
} }
}

View File

@ -17,8 +17,8 @@ using System.Text;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace CryptoExchange.Net.Clients namespace CryptoExchange.Net.Clients;
{
/// <summary> /// <summary>
/// Base socket API client for interaction with a websocket API /// Base socket API client for interaction with a websocket API
/// </summary> /// </summary>
@ -86,7 +86,7 @@ namespace CryptoExchange.Net.Clients
/// <summary> /// <summary>
/// Whether to continue processing and forward unparsable messages to handlers /// Whether to continue processing and forward unparsable messages to handlers
/// </summary> /// </summary>
protected internal bool ProcessUnparsableMessages { get; set; } = false; protected internal bool ProcessUnparsableMessages { get; set; }
/// <inheritdoc /> /// <inheritdoc />
public double IncomingKbps public double IncomingKbps
@ -340,7 +340,13 @@ namespace CryptoExchange.Net.Clients
SocketConnection socketConnection; SocketConnection socketConnection;
var released = false; var released = false;
await semaphoreSlim.WaitAsync().ConfigureAwait(false);
try
{
await semaphoreSlim.WaitAsync(ct).ConfigureAwait(false);
}
catch (OperationCanceledException) { }
try try
{ {
var socketResult = await GetSocketConnection(url, query.Authenticated, true).ConfigureAwait(false); var socketResult = await GetSocketConnection(url, query.Authenticated, true).ConfigureAwait(false);
@ -395,7 +401,13 @@ namespace CryptoExchange.Net.Clients
return connectResult; return connectResult;
if (ClientOptions.DelayAfterConnect != TimeSpan.Zero) if (ClientOptions.DelayAfterConnect != TimeSpan.Zero)
await Task.Delay(ClientOptions.DelayAfterConnect).ConfigureAwait(false); {
try
{
await Task.Delay(ClientOptions.DelayAfterConnect, ct).ConfigureAwait(false);
}
catch (OperationCanceledException) { }
}
if (!authenticated || socket.Authenticated) if (!authenticated || socket.Authenticated)
return CallResult.SuccessResult; return CallResult.SuccessResult;
@ -862,4 +874,3 @@ namespace CryptoExchange.Net.Clients
/// <returns></returns> /// <returns></returns>
public virtual ReadOnlyMemory<byte> PreprocessStreamMessage(SocketConnection connection, WebSocketMessageType type, ReadOnlyMemory<byte> data) => data; public virtual ReadOnlyMemory<byte> PreprocessStreamMessage(SocketConnection connection, WebSocketMessageType type, ReadOnlyMemory<byte> data) => data;
} }
}

View File

@ -1,7 +1,7 @@
using System; using System;
namespace CryptoExchange.Net.Converters;
namespace CryptoExchange.Net.Converters
{
/// <summary> /// <summary>
/// Mark property as an index in the array /// Mark property as an index in the array
/// </summary> /// </summary>
@ -22,4 +22,3 @@ namespace CryptoExchange.Net.Converters
Index = index; Index = index;
} }
} }
}

View File

@ -1,11 +1,9 @@
using System; using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Text;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
namespace CryptoExchange.Net.Converters namespace CryptoExchange.Net.Converters;
{
/// <summary> /// <summary>
/// Caching for JsonSerializerContext instances /// Caching for JsonSerializerContext instances
/// </summary> /// </summary>
@ -28,4 +26,3 @@ namespace CryptoExchange.Net.Converters
return instance; return instance;
} }
} }
}

View File

@ -1,5 +1,5 @@
namespace CryptoExchange.Net.Converters.MessageParsing namespace CryptoExchange.Net.Converters.MessageParsing;
{
/// <summary> /// <summary>
/// Node accessor /// Node accessor
/// </summary> /// </summary>
@ -46,4 +46,3 @@
/// <returns></returns> /// <returns></returns>
public static NodeAccessor PropertyName() { return new NodeAccessor(null, null, 2); } public static NodeAccessor PropertyName() { return new NodeAccessor(null, null, 2); }
} }
}

View File

@ -1,8 +1,8 @@
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
namespace CryptoExchange.Net.Converters.MessageParsing namespace CryptoExchange.Net.Converters.MessageParsing;
{
/// <summary> /// <summary>
/// Message access definition /// Message access definition
/// </summary> /// </summary>
@ -47,4 +47,3 @@ namespace CryptoExchange.Net.Converters.MessageParsing
return GetEnumerator(); return GetEnumerator();
} }
} }
}

View File

@ -1,5 +1,5 @@
namespace CryptoExchange.Net.Converters.MessageParsing namespace CryptoExchange.Net.Converters.MessageParsing;
{
/// <summary> /// <summary>
/// Message path extension methods /// Message path extension methods
/// </summary> /// </summary>
@ -40,4 +40,3 @@
return path; return path;
} }
} }
}

View File

@ -1,5 +1,5 @@
namespace CryptoExchange.Net.Converters.MessageParsing namespace CryptoExchange.Net.Converters.MessageParsing;
{
/// <summary> /// <summary>
/// Message node type /// Message node type
/// </summary> /// </summary>
@ -18,4 +18,3 @@
/// </summary> /// </summary>
Value Value
} }
}

View File

@ -1,18 +1,17 @@
using System; using System;
using System.Collections.Concurrent;
using System.Globalization; using System.Globalization;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
using System.Text.Json; using System.Text.Json;
using CryptoExchange.Net.Attributes;
using System.Collections.Generic; using System.Collections.Generic;
#if NET5_0_OR_GREATER
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
#endif
using System.Threading; using System.Threading;
using System.Diagnostics;
namespace CryptoExchange.Net.Converters.SystemTextJson namespace CryptoExchange.Net.Converters.SystemTextJson;
{
/// <summary> /// <summary>
/// Converter for arrays to objects. Can deserialize data like [0.1, 0.2, "test"] to an object. Mapping is done by marking the class with [JsonConverter(typeof(ArrayConverter))] and the properties /// Converter for arrays to objects. Can deserialize data like [0.1, 0.2, "test"] to an object. Mapping is done by marking the class with [JsonConverter(typeof(ArrayConverter))] and the properties
/// with [ArrayProperty(x)] where x is the index of the property in the array /// with [ArrayProperty(x)] where x is the index of the property in the array
@ -228,7 +227,6 @@ namespace CryptoExchange.Net.Converters.SystemTextJson
public JsonConverter? JsonConverter { get; set; } public JsonConverter? JsonConverter { get; set; }
public bool DefaultDeserialization { get; set; } public bool DefaultDeserialization { get; set; }
public Type TargetType { get; set; } = null!; public Type TargetType { get; set; } = null!;
public JsonSerializerOptions? JsonSerializerOptions { get; set; } = null; public JsonSerializerOptions? JsonSerializerOptions { get; set; }
}
} }
} }

View File

@ -1,10 +1,10 @@
using System; using System;
using System.Globalization; using System.Globalization;
using System.Text.Json; using System.Text.Json;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
namespace CryptoExchange.Net.Converters.SystemTextJson namespace CryptoExchange.Net.Converters.SystemTextJson;
{
/// <summary> /// <summary>
/// Decimal converter that handles overflowing decimal values (by setting it to decimal.MaxValue) /// Decimal converter that handles overflowing decimal values (by setting it to decimal.MaxValue)
/// </summary> /// </summary>
@ -43,4 +43,3 @@ namespace CryptoExchange.Net.Converters.SystemTextJson
writer.WriteNumberValue(value); writer.WriteNumberValue(value);
} }
} }
}

View File

@ -1,11 +1,11 @@
using System; using System;
using System.Diagnostics; using System.Diagnostics;
using System.Runtime.Serialization; using System.Runtime.Serialization;
using System.Text.Json; using System.Text.Json;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
namespace CryptoExchange.Net.Converters.SystemTextJson namespace CryptoExchange.Net.Converters.SystemTextJson;
{
/// <summary> /// <summary>
/// Bool converter /// Bool converter
/// </summary> /// </summary>
@ -28,7 +28,7 @@ namespace CryptoExchange.Net.Converters.SystemTextJson
public override T Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) public override T Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
=> (T)((object?)ReadBool(ref reader, typeToConvert, options) ?? default(T))!; => (T)((object?)ReadBool(ref reader, typeToConvert, options) ?? default(T))!;
public bool? ReadBool(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) public static bool? ReadBool(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{ {
if (reader.TokenType == JsonTokenType.True) if (reader.TokenType == JsonTokenType.True)
return true; return true;
@ -81,4 +81,3 @@ namespace CryptoExchange.Net.Converters.SystemTextJson
} }
} }
}

View File

@ -1,13 +1,13 @@
using System; using System;
using System.Collections.Generic; #if NET5_0_OR_GREATER
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
#endif
using System.Linq; using System.Linq;
using System.Text;
using System.Text.Json; using System.Text.Json;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
namespace CryptoExchange.Net.Converters.SystemTextJson namespace CryptoExchange.Net.Converters.SystemTextJson;
{
/// <summary> /// <summary>
/// Converter for comma separated enum values /// Converter for comma separated enum values
/// </summary> /// </summary>
@ -34,4 +34,3 @@ namespace CryptoExchange.Net.Converters.SystemTextJson
writer.WriteStringValue(string.Join(",", value.Select(x => EnumConverter.GetString(x)))); writer.WriteStringValue(string.Join(",", value.Select(x => EnumConverter.GetString(x))));
} }
} }
}

View File

@ -1,12 +1,12 @@
using System; using System;
using System.Diagnostics; using System.Diagnostics;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.Globalization; using System.Globalization;
using System.Text.Json; using System.Text.Json;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
namespace CryptoExchange.Net.Converters.SystemTextJson namespace CryptoExchange.Net.Converters.SystemTextJson;
{
/// <summary> /// <summary>
/// Date time converter /// Date time converter
/// </summary> /// </summary>
@ -34,7 +34,7 @@ namespace CryptoExchange.Net.Converters.SystemTextJson
public override T Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) public override T Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
=> (T)((object?)ReadDateTime(ref reader, typeToConvert, options) ?? default(T))!; => (T)((object?)ReadDateTime(ref reader, typeToConvert, options) ?? default(T))!;
private DateTime? ReadDateTime(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) private static DateTime? ReadDateTime(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{ {
if (reader.TokenType == JsonTokenType.Null) if (reader.TokenType == JsonTokenType.Null)
{ {
@ -239,4 +239,3 @@ namespace CryptoExchange.Net.Converters.SystemTextJson
[return: NotNullIfNotNull("time")] [return: NotNullIfNotNull("time")]
public static long? ConvertToNanoseconds(DateTime? time) => time == null ? null : (long)Math.Round((time.Value - _epoch).Ticks / _ticksPerNanosecond); public static long? ConvertToNanoseconds(DateTime? time) => time == null ? null : (long)Math.Round((time.Value - _epoch).Ticks / _ticksPerNanosecond);
} }
}

View File

@ -1,10 +1,9 @@
using System; using System;
using System.Globalization;
using System.Text.Json; using System.Text.Json;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
namespace CryptoExchange.Net.Converters.SystemTextJson namespace CryptoExchange.Net.Converters.SystemTextJson;
{
/// <summary> /// <summary>
/// Decimal converter /// Decimal converter
/// </summary> /// </summary>
@ -42,4 +41,3 @@ namespace CryptoExchange.Net.Converters.SystemTextJson
writer.WriteNumberValue(value.Value); writer.WriteNumberValue(value.Value);
} }
} }
}

View File

@ -1,10 +1,10 @@
using System; using System;
using System.Globalization; using System.Globalization;
using System.Text.Json; using System.Text.Json;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
namespace CryptoExchange.Net.Converters.SystemTextJson namespace CryptoExchange.Net.Converters.SystemTextJson;
{
/// <summary> /// <summary>
/// Converter for serializing decimal values as string /// Converter for serializing decimal values as string
/// </summary> /// </summary>
@ -20,4 +20,3 @@ namespace CryptoExchange.Net.Converters.SystemTextJson
public override void Write(Utf8JsonWriter writer, decimal value, JsonSerializerOptions options) public override void Write(Utf8JsonWriter writer, decimal value, JsonSerializerOptions options)
=> writer.WriteStringValue(value.ToString(CultureInfo.InvariantCulture) ?? null); => writer.WriteStringValue(value.ToString(CultureInfo.InvariantCulture) ?? null);
} }
}

View File

@ -1,4 +1,4 @@
using CryptoExchange.Net.Attributes; using CryptoExchange.Net.Attributes;
using System; using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
@ -9,8 +9,8 @@ using System.Reflection;
using System.Text.Json; using System.Text.Json;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
namespace CryptoExchange.Net.Converters.SystemTextJson namespace CryptoExchange.Net.Converters.SystemTextJson;
{
/// <summary> /// <summary>
/// Static EnumConverter methods /// Static EnumConverter methods
/// </summary> /// </summary>
@ -64,8 +64,8 @@ namespace CryptoExchange.Net.Converters.SystemTextJson
#endif #endif
: JsonConverter<T>, INullableConverterFactory where T : struct, Enum : JsonConverter<T>, INullableConverterFactory where T : struct, Enum
{ {
private static List<KeyValuePair<T, string>>? _mapping = null; private static List<KeyValuePair<T, string>>? _mapping;
private NullableEnumConverter? _nullableEnumConverter = null; private NullableEnumConverter? _nullableEnumConverter;
private static ConcurrentBag<string> _unknownValuesWarned = new ConcurrentBag<string>(); private static ConcurrentBag<string> _unknownValuesWarned = new ConcurrentBag<string>();
@ -79,7 +79,7 @@ namespace CryptoExchange.Net.Converters.SystemTextJson
} }
public override T? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) public override T? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{ {
return _enumConverter.ReadNullable(ref reader, typeToConvert, options, out var isEmptyString, out var warn); return EnumConverter<T>.ReadNullable(ref reader, typeToConvert, options, out var isEmptyString, out var warn);
} }
public override void Write(Utf8JsonWriter writer, T? value, JsonSerializerOptions options) public override void Write(Utf8JsonWriter writer, T? value, JsonSerializerOptions options)
@ -122,7 +122,7 @@ namespace CryptoExchange.Net.Converters.SystemTextJson
} }
} }
private T? ReadNullable(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options, out bool isEmptyString, out bool warn) private static T? ReadNullable(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options, out bool isEmptyString, out bool warn)
{ {
isEmptyString = false; isEmptyString = false;
warn = false; warn = false;
@ -286,4 +286,3 @@ namespace CryptoExchange.Net.Converters.SystemTextJson
return _nullableEnumConverter; return _nullableEnumConverter;
} }
} }
}

View File

@ -1,10 +1,9 @@
using System; using System;
using System.Globalization;
using System.Text.Json; using System.Text.Json;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
namespace CryptoExchange.Net.Converters.SystemTextJson namespace CryptoExchange.Net.Converters.SystemTextJson;
{
/// <summary> /// <summary>
/// Converter for serializing enum values as int /// Converter for serializing enum values as int
/// </summary> /// </summary>
@ -20,4 +19,3 @@ namespace CryptoExchange.Net.Converters.SystemTextJson
public override void Write(Utf8JsonWriter writer, T value, JsonSerializerOptions options) public override void Write(Utf8JsonWriter writer, T value, JsonSerializerOptions options)
=> writer.WriteNumberValue((int)(object)value); => writer.WriteNumberValue((int)(object)value);
} }
}

View File

@ -1,9 +1,8 @@
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
namespace CryptoExchange.Net.Converters.SystemTextJson;
namespace CryptoExchange.Net.Converters.SystemTextJson
{
internal interface INullableConverterFactory internal interface INullableConverterFactory
{ {
JsonConverter CreateNullableConverter(); JsonConverter CreateNullableConverter();
} }
}

View File

@ -1,10 +1,10 @@
using System; using System;
using System.Globalization; using System.Globalization;
using System.Text.Json; using System.Text.Json;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
namespace CryptoExchange.Net.Converters.SystemTextJson namespace CryptoExchange.Net.Converters.SystemTextJson;
{
/// <summary> /// <summary>
/// Int converter /// Int converter
/// </summary> /// </summary>
@ -37,4 +37,3 @@ namespace CryptoExchange.Net.Converters.SystemTextJson
writer.WriteNumberValue(value.Value); writer.WriteNumberValue(value.Value);
} }
} }
}

View File

@ -1,10 +1,10 @@
using System; using System;
using System.Globalization; using System.Globalization;
using System.Text.Json; using System.Text.Json;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
namespace CryptoExchange.Net.Converters.SystemTextJson namespace CryptoExchange.Net.Converters.SystemTextJson;
{
/// <summary> /// <summary>
/// Int converter /// Int converter
/// </summary> /// </summary>
@ -37,4 +37,3 @@ namespace CryptoExchange.Net.Converters.SystemTextJson
writer.WriteNumberValue(value.Value); writer.WriteNumberValue(value.Value);
} }
} }
}

View File

@ -1,12 +1,10 @@
using System; using System;
using System.Collections.Generic;
using System.Text;
using System.Text.Json.Serialization.Metadata; using System.Text.Json.Serialization.Metadata;
using System.Text.Json; using System.Text.Json;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
namespace CryptoExchange.Net.Converters.SystemTextJson namespace CryptoExchange.Net.Converters.SystemTextJson;
{
internal class NullableEnumConverterFactory : JsonConverterFactory internal class NullableEnumConverterFactory : JsonConverterFactory
{ {
private readonly IJsonTypeInfoResolver _jsonTypeInfoResolver; private readonly IJsonTypeInfoResolver _jsonTypeInfoResolver;
@ -40,4 +38,3 @@ namespace CryptoExchange.Net.Converters.SystemTextJson
return nullConverterFactory.CreateNullableConverter(); return nullConverterFactory.CreateNullableConverter();
} }
} }
}

View File

@ -1,9 +1,9 @@
using System; using System;
using System.Text.Json; using System.Text.Json;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
namespace CryptoExchange.Net.Converters.SystemTextJson namespace CryptoExchange.Net.Converters.SystemTextJson;
{
/// <summary> /// <summary>
/// Read string or number as string /// Read string or number as string
/// </summary> /// </summary>
@ -39,4 +39,3 @@ namespace CryptoExchange.Net.Converters.SystemTextJson
writer.WriteStringValue(value); writer.WriteStringValue(value);
} }
} }
}

View File

@ -1,10 +1,12 @@
using System; using System;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
using System.Text.Json; using System.Text.Json;
#if NET5_0_OR_GREATER
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
#endif
namespace CryptoExchange.Net.Converters.SystemTextJson;
namespace CryptoExchange.Net.Converters.SystemTextJson
{
/// <summary> /// <summary>
/// Converter for values which contain a nested json value /// Converter for values which contain a nested json value
/// </summary> /// </summary>
@ -24,7 +26,7 @@ namespace CryptoExchange.Net.Converters.SystemTextJson
if (string.IsNullOrEmpty(value)) if (string.IsNullOrEmpty(value))
return default; return default;
return (T?)JsonDocument.Parse(value!).Deserialize(typeof(T), options); return JsonDocument.Parse(value!).Deserialize<T>(options);
} }
/// <inheritdoc /> /// <inheritdoc />
@ -40,4 +42,3 @@ namespace CryptoExchange.Net.Converters.SystemTextJson
writer.WriteStringValue(JsonSerializer.Serialize(value, options)); writer.WriteStringValue(JsonSerializer.Serialize(value, options));
} }
} }
}

View File

@ -1,10 +1,10 @@
using System; using System;
using System.Linq; using System.Linq;
using System.Text.Json; using System.Text.Json;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
namespace CryptoExchange.Net.Converters.SystemTextJson namespace CryptoExchange.Net.Converters.SystemTextJson;
{
/// <summary> /// <summary>
/// Replace a value on a string property /// Replace a value on a string property
/// </summary> /// </summary>
@ -19,7 +19,7 @@ namespace CryptoExchange.Net.Converters.SystemTextJson
{ {
_replacementSets = replaceSets.Select(x => _replacementSets = replaceSets.Select(x =>
{ {
var split = x.Split(new string[] { "->" }, StringSplitOptions.None); var split = x.Split(["->"], StringSplitOptions.None);
if (split.Length != 2) if (split.Length != 2)
throw new ArgumentException("Invalid replacement config"); throw new ArgumentException("Invalid replacement config");
return (split[0], split[1]); return (split[0], split[1]);
@ -38,4 +38,3 @@ namespace CryptoExchange.Net.Converters.SystemTextJson
/// <inheritdoc /> /// <inheritdoc />
public override void Write(Utf8JsonWriter writer, string value, JsonSerializerOptions options) => writer.WriteStringValue(value); public override void Write(Utf8JsonWriter writer, string value, JsonSerializerOptions options) => writer.WriteStringValue(value);
} }
}

View File

@ -1,9 +1,7 @@
using System; using System;
using System.Collections.Generic;
using System.Text; namespace CryptoExchange.Net.Converters.SystemTextJson;
namespace CryptoExchange.Net.Converters.SystemTextJson
{
/// <summary> /// <summary>
/// Attribute to mark a model as json serializable. Used for AOT compilation. /// Attribute to mark a model as json serializable. Used for AOT compilation.
/// </summary> /// </summary>
@ -20,4 +18,3 @@ namespace CryptoExchange.Net.Converters.SystemTextJson
/// <param name="type"></param> /// <param name="type"></param>
public SerializationModelAttribute(Type type) { } public SerializationModelAttribute(Type type) { }
} }
}

View File

@ -1,9 +1,9 @@
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Text.Json; using System.Text.Json;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
namespace CryptoExchange.Net.Converters.SystemTextJson namespace CryptoExchange.Net.Converters.SystemTextJson;
{
/// <summary> /// <summary>
/// Serializer options /// Serializer options
/// </summary> /// </summary>
@ -44,4 +44,3 @@ namespace CryptoExchange.Net.Converters.SystemTextJson
return options; return options;
} }
} }
}

View File

@ -1,12 +1,10 @@
using CryptoExchange.Net.SharedApis; using CryptoExchange.Net.SharedApis;
using System; using System;
using System.Collections.Generic;
using System.Text;
using System.Text.Json; using System.Text.Json;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
namespace CryptoExchange.Net.Converters.SystemTextJson namespace CryptoExchange.Net.Converters.SystemTextJson;
{
internal class SharedQuantityConverter : SharedQuantityReferenceConverter<SharedQuantity> { } internal class SharedQuantityConverter : SharedQuantityReferenceConverter<SharedQuantity> { }
internal class SharedOrderQuantityConverter : SharedQuantityReferenceConverter<SharedOrderQuantity> { } internal class SharedOrderQuantityConverter : SharedQuantityReferenceConverter<SharedOrderQuantity> { }
@ -57,4 +55,3 @@ namespace CryptoExchange.Net.Converters.SystemTextJson
writer.WriteEndArray(); writer.WriteEndArray();
} }
} }
}

View File

@ -1,12 +1,10 @@
using CryptoExchange.Net.SharedApis; using CryptoExchange.Net.SharedApis;
using System; using System;
using System.Collections.Generic;
using System.Text;
using System.Text.Json; using System.Text.Json;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
namespace CryptoExchange.Net.Converters.SystemTextJson namespace CryptoExchange.Net.Converters.SystemTextJson;
{
internal class SharedSymbolConverter : JsonConverter<SharedSymbol> internal class SharedSymbolConverter : JsonConverter<SharedSymbol>
{ {
public override SharedSymbol? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) public override SharedSymbol? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
@ -43,4 +41,3 @@ namespace CryptoExchange.Net.Converters.SystemTextJson
writer.WriteEndArray(); writer.WriteEndArray();
} }
} }
}

View File

@ -1,16 +1,17 @@
using CryptoExchange.Net.Converters.MessageParsing; using CryptoExchange.Net.Converters.MessageParsing;
using CryptoExchange.Net.Interfaces; using CryptoExchange.Net.Interfaces;
using CryptoExchange.Net.Objects; using CryptoExchange.Net.Objects;
using System; using System;
using System.Collections.Generic; #if NET5_0_OR_GREATER
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
#endif
using System.IO; using System.IO;
using System.Text; using System.Text;
using System.Text.Json; using System.Text.Json;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace CryptoExchange.Net.Converters.SystemTextJson namespace CryptoExchange.Net.Converters.SystemTextJson;
{
/// <summary> /// <summary>
/// System.Text.Json message accessor /// System.Text.Json message accessor
/// </summary> /// </summary>
@ -240,7 +241,9 @@ namespace CryptoExchange.Net.Converters.SystemTextJson
/// <summary> /// <summary>
/// System.Text.Json stream message accessor /// System.Text.Json stream message accessor
/// </summary> /// </summary>
#pragma warning disable CA1001 // Types that own disposable fields should be disposable
public class SystemTextJsonStreamMessageAccessor : SystemTextJsonMessageAccessor, IStreamMessageAccessor public class SystemTextJsonStreamMessageAccessor : SystemTextJsonMessageAccessor, IStreamMessageAccessor
#pragma warning restore CA1001 // Types that own disposable fields should be disposable
{ {
private Stream? _stream; private Stream? _stream;
@ -371,4 +374,3 @@ namespace CryptoExchange.Net.Converters.SystemTextJson
_document = null; _document = null;
} }
} }
}

View File

@ -1,11 +1,11 @@
using CryptoExchange.Net.Interfaces; using CryptoExchange.Net.Interfaces;
#if NET5_0_OR_GREATER
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
#endif
using System.Text.Json; using System.Text.Json;
using System.Text.Json.Serialization;
using System.Text.Json.Serialization.Metadata;
namespace CryptoExchange.Net.Converters.SystemTextJson namespace CryptoExchange.Net.Converters.SystemTextJson;
{
/// <inheritdoc /> /// <inheritdoc />
public class SystemTextJsonMessageSerializer : IStringMessageSerializer public class SystemTextJsonMessageSerializer : IStringMessageSerializer
{ {
@ -26,4 +26,3 @@ namespace CryptoExchange.Net.Converters.SystemTextJson
#endif #endif
public string Serialize<T>(T message) => JsonSerializer.Serialize(message, _options); public string Serialize<T>(T message) => JsonSerializer.Serialize(message, _options);
} }
}

View File

@ -24,6 +24,7 @@
<PackageLicenseExpression>MIT</PackageLicenseExpression> <PackageLicenseExpression>MIT</PackageLicenseExpression>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<None Include="C:\Projects\CryptoExchange.Net\CryptoExchange.Net\.editorconfig" />
<None Include="Icon\icon.png" Pack="true" PackagePath="\" /> <None Include="Icon\icon.png" Pack="true" PackagePath="\" />
<None Include="..\README.md" Pack="true" PackagePath="\" /> <None Include="..\README.md" Pack="true" PackagePath="\" />
</ItemGroup> </ItemGroup>
@ -40,6 +41,12 @@
<PropertyGroup> <PropertyGroup>
<DocumentationFile>CryptoExchange.Net.xml</DocumentationFile> <DocumentationFile>CryptoExchange.Net.xml</DocumentationFile>
</PropertyGroup> </PropertyGroup>
<PropertyGroup>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<AnalysisMode>Recommended</AnalysisMode>
<AnalysisModeGlobalization>None</AnalysisModeGlobalization>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="ConfigureAwaitChecker.Analyzer" Version="5.0.0.1"> <PackageReference Include="ConfigureAwaitChecker.Analyzer" Version="5.0.0.1">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
@ -58,4 +65,7 @@
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="9.0.6" /> <PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="9.0.6" />
<PackageReference Include="Microsoft.Extensions.Http" Version="9.0.6" /> <PackageReference Include="Microsoft.Extensions.Http" Version="9.0.6" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<EditorConfigFiles Remove="C:\Projects\CryptoExchange.Net\CryptoExchange.Net\.editorconfig" />
</ItemGroup>
</Project> </Project>

View File

@ -1,15 +1,17 @@
using CryptoExchange.Net.Objects; using CryptoExchange.Net.Objects;
using CryptoExchange.Net.SharedApis; using CryptoExchange.Net.SharedApis;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
#if NETSTANDARD2_1_OR_GREATER || NET9_0_OR_GREATER
using System.Security.Cryptography; using System.Security.Cryptography;
#endif
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace CryptoExchange.Net namespace CryptoExchange.Net;
{
/// <summary> /// <summary>
/// General helpers functions /// General helpers functions
/// </summary> /// </summary>
@ -287,16 +289,16 @@ namespace CryptoExchange.Net
/// <summary> /// <summary>
/// Execute multiple requests to retrieve multiple pages of the result set /// Execute multiple requests to retrieve multiple pages of the result set
/// </summary> /// </summary>
/// <typeparam name="T">Type of the client</typeparam> /// <typeparam name="TResult">Type of the client</typeparam>
/// <typeparam name="U">Type of the request</typeparam> /// <typeparam name="TRequest">Type of the request</typeparam>
/// <param name="paginatedFunc">The func to execute with each request</param> /// <param name="paginatedFunc">The func to execute with each request</param>
/// <param name="request">The request parameters</param> /// <param name="request">The request parameters</param>
/// <param name="ct">Cancellation token</param> /// <param name="ct">Cancellation token</param>
/// <returns></returns> /// <returns></returns>
public static async IAsyncEnumerable<ExchangeWebResult<T[]>> ExecutePages<T, U>(Func<U, INextPageToken?, CancellationToken, Task<ExchangeWebResult<T[]>>> paginatedFunc, U request, [EnumeratorCancellation]CancellationToken ct = default) public static async IAsyncEnumerable<ExchangeWebResult<TResult[]>> ExecutePages<TResult, TRequest>(Func<TRequest, INextPageToken?, CancellationToken, Task<ExchangeWebResult<TResult[]>>> paginatedFunc, TRequest request, [EnumeratorCancellation]CancellationToken ct = default)
{ {
var result = new List<T>(); var result = new List<TResult>();
ExchangeWebResult<T[]> batch; ExchangeWebResult<TResult[]> batch;
INextPageToken? nextPageToken = null; INextPageToken? nextPageToken = null;
while (true) while (true)
{ {
@ -386,4 +388,3 @@ namespace CryptoExchange.Net
return null; return null;
} }
} }
}

View File

@ -1,12 +1,11 @@
using CryptoExchange.Net.SharedApis; using CryptoExchange.Net.SharedApis;
using System; using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text;
namespace CryptoExchange.Net namespace CryptoExchange.Net;
{
/// <summary> /// <summary>
/// Cache for symbol parsing /// Cache for symbol parsing
/// </summary> /// </summary>
@ -67,4 +66,3 @@ namespace CryptoExchange.Net
} }
} }
} }
}

View File

@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO.Compression; using System.IO.Compression;
using System.IO; using System.IO;
@ -10,12 +10,9 @@ using CryptoExchange.Net.Objects;
using System.Globalization; using System.Globalization;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using CryptoExchange.Net.SharedApis; using CryptoExchange.Net.SharedApis;
using System.Text.Json.Serialization.Metadata;
using System.Text.Json;
using System.Text.Json.Serialization;
namespace CryptoExchange.Net namespace CryptoExchange.Net;
{
/// <summary> /// <summary>
/// Helper methods /// Helper methods
/// </summary> /// </summary>
@ -520,5 +517,4 @@ namespace CryptoExchange.Net
return services; return services;
} }
} }
}

View File

@ -1,7 +1,7 @@
using System; using System;
namespace CryptoExchange.Net.Interfaces;
namespace CryptoExchange.Net.Interfaces
{
/// <summary> /// <summary>
/// Time provider /// Time provider
/// </summary> /// </summary>
@ -13,4 +13,3 @@ namespace CryptoExchange.Net.Interfaces
/// <returns></returns> /// <returns></returns>
DateTime GetTime(); DateTime GetTime();
} }
}

View File

@ -1,11 +1,10 @@
using CryptoExchange.Net.Authentication; using CryptoExchange.Net.Authentication;
using CryptoExchange.Net.Objects;
using CryptoExchange.Net.Objects.Options; using CryptoExchange.Net.Objects.Options;
using CryptoExchange.Net.SharedApis; using CryptoExchange.Net.SharedApis;
using System; using System;
namespace CryptoExchange.Net.Interfaces namespace CryptoExchange.Net.Interfaces;
{
/// <summary> /// <summary>
/// Base api client /// Base api client
/// </summary> /// </summary>
@ -45,4 +44,3 @@ namespace CryptoExchange.Net.Interfaces
/// <param name="options">Options to set</param> /// <param name="options">Options to set</param>
void SetOptions<T>(UpdateOptions<T> options) where T : ApiCredentials; void SetOptions<T>(UpdateOptions<T> options) where T : ApiCredentials;
} }
}

View File

@ -1,7 +1,7 @@
using System; using System;
namespace CryptoExchange.Net.Interfaces;
namespace CryptoExchange.Net.Interfaces
{
/// <summary> /// <summary>
/// Client for accessing REST API's for different exchanges /// Client for accessing REST API's for different exchanges
/// </summary> /// </summary>
@ -14,4 +14,3 @@ namespace CryptoExchange.Net.Interfaces
/// <returns></returns> /// <returns></returns>
T TryGet<T>(Func<T> createFunc); T TryGet<T>(Func<T> createFunc);
} }
}

View File

@ -1,7 +1,7 @@
using System; using System;
namespace CryptoExchange.Net.Interfaces;
namespace CryptoExchange.Net.Interfaces
{
/// <summary> /// <summary>
/// Client for accessing Websocket API's for different exchanges /// Client for accessing Websocket API's for different exchanges
/// </summary> /// </summary>
@ -14,4 +14,3 @@ namespace CryptoExchange.Net.Interfaces
/// <returns></returns> /// <returns></returns>
T TryGet<T>(Func<T> createFunc); T TryGet<T>(Func<T> createFunc);
} }
}

View File

@ -1,13 +1,14 @@
using CryptoExchange.Net.Converters.MessageParsing; using CryptoExchange.Net.Converters.MessageParsing;
using CryptoExchange.Net.Objects; using CryptoExchange.Net.Objects;
using System; using System;
using System.Collections.Generic; #if NET5_0_OR_GREATER
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
#endif
using System.IO; using System.IO;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace CryptoExchange.Net.Interfaces namespace CryptoExchange.Net.Interfaces;
{
/// <summary> /// <summary>
/// Message accessor /// Message accessor
/// </summary> /// </summary>
@ -107,4 +108,3 @@ namespace CryptoExchange.Net.Interfaces
/// <param name="data"></param> /// <param name="data"></param>
CallResult Read(ReadOnlyMemory<byte> data); CallResult Read(ReadOnlyMemory<byte> data);
} }
}

View File

@ -1,12 +1,11 @@
using CryptoExchange.Net.Objects; using CryptoExchange.Net.Objects;
using CryptoExchange.Net.Objects.Sockets; using CryptoExchange.Net.Objects.Sockets;
using CryptoExchange.Net.Sockets; using CryptoExchange.Net.Sockets;
using System; using System;
using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace CryptoExchange.Net.Interfaces namespace CryptoExchange.Net.Interfaces;
{
/// <summary> /// <summary>
/// Message processor /// Message processor
/// </summary> /// </summary>
@ -32,4 +31,3 @@ namespace CryptoExchange.Net.Interfaces
/// <returns></returns> /// <returns></returns>
CallResult<object> Deserialize(IMessageAccessor accessor, Type type); CallResult<object> Deserialize(IMessageAccessor accessor, Type type);
} }
}

View File

@ -1,7 +1,5 @@
using System.Diagnostics.CodeAnalysis; namespace CryptoExchange.Net.Interfaces;
namespace CryptoExchange.Net.Interfaces
{
/// <summary> /// <summary>
/// Serializer interface /// Serializer interface
/// </summary> /// </summary>
@ -34,4 +32,3 @@ namespace CryptoExchange.Net.Interfaces
/// <returns></returns> /// <returns></returns>
string Serialize<T>(T message); string Serialize<T>(T message);
} }
}

View File

@ -1,5 +1,5 @@
namespace CryptoExchange.Net.Interfaces namespace CryptoExchange.Net.Interfaces;
{
/// <summary> /// <summary>
/// A provider for a nonce value used when signing requests /// A provider for a nonce value used when signing requests
/// </summary> /// </summary>
@ -11,4 +11,3 @@
/// <returns>Nonce value</returns> /// <returns>Nonce value</returns>
long GetNonce(); long GetNonce();
} }
}

View File

@ -1,9 +1,9 @@
using CryptoExchange.Net.Objects.Options; using CryptoExchange.Net.Objects.Options;
using CryptoExchange.Net.SharedApis; using CryptoExchange.Net.SharedApis;
using System; using System;
namespace CryptoExchange.Net.Interfaces namespace CryptoExchange.Net.Interfaces;
{
/// <summary> /// <summary>
/// Factory for ISymbolOrderBook instances /// Factory for ISymbolOrderBook instances
/// </summary> /// </summary>
@ -32,4 +32,3 @@ namespace CryptoExchange.Net.Interfaces
/// <returns></returns> /// <returns></returns>
public ISymbolOrderBook Create(SharedSymbol symbol, Action<TOptions>? options = null); public ISymbolOrderBook Create(SharedSymbol symbol, Action<TOptions>? options = null);
} }
}

View File

@ -4,8 +4,8 @@ using System.Net.Http;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace CryptoExchange.Net.Interfaces namespace CryptoExchange.Net.Interfaces;
{
/// <summary> /// <summary>
/// Rate limiter interface /// Rate limiter interface
/// </summary> /// </summary>
@ -25,4 +25,3 @@ namespace CryptoExchange.Net.Interfaces
/// <returns>The time in milliseconds spend waiting</returns> /// <returns>The time in milliseconds spend waiting</returns>
Task<CallResult<int>> LimitRequestAsync(ILogger log, string endpoint, HttpMethod method, bool signed, string? apiKey, RateLimitingBehaviour limitBehaviour, int requestWeight, CancellationToken ct); Task<CallResult<int>> LimitRequestAsync(ILogger log, string endpoint, HttpMethod method, bool signed, string? apiKey, RateLimitingBehaviour limitBehaviour, int requestWeight, CancellationToken ct);
} }
}

View File

@ -1,11 +1,11 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Net.Http; using System.Net.Http;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace CryptoExchange.Net.Interfaces namespace CryptoExchange.Net.Interfaces;
{
/// <summary> /// <summary>
/// Request interface /// Request interface
/// </summary> /// </summary>
@ -63,4 +63,3 @@ namespace CryptoExchange.Net.Interfaces
/// <returns></returns> /// <returns></returns>
Task<IResponse> GetResponseAsync(CancellationToken cancellationToken); Task<IResponse> GetResponseAsync(CancellationToken cancellationToken);
} }
}

View File

@ -1,9 +1,9 @@
using CryptoExchange.Net.Objects; using CryptoExchange.Net.Objects;
using System; using System;
using System.Net.Http; using System.Net.Http;
namespace CryptoExchange.Net.Interfaces namespace CryptoExchange.Net.Interfaces;
{
/// <summary> /// <summary>
/// Request factory interface /// Request factory interface
/// </summary> /// </summary>
@ -33,4 +33,3 @@ namespace CryptoExchange.Net.Interfaces
/// <param name="requestTimeout">Request timeout to use</param> /// <param name="requestTimeout">Request timeout to use</param>
void UpdateSettings(ApiProxy? proxy, TimeSpan requestTimeout); void UpdateSettings(ApiProxy? proxy, TimeSpan requestTimeout);
} }
}

View File

@ -1,10 +1,10 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Net; using System.Net;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace CryptoExchange.Net.Interfaces namespace CryptoExchange.Net.Interfaces;
{
/// <summary> /// <summary>
/// Response object interface /// Response object interface
/// </summary> /// </summary>
@ -41,4 +41,3 @@ namespace CryptoExchange.Net.Interfaces
/// </summary> /// </summary>
void Close(); void Close();
} }
}

View File

@ -1,5 +1,5 @@
namespace CryptoExchange.Net.Interfaces namespace CryptoExchange.Net.Interfaces;
{
/// <summary> /// <summary>
/// Base rest API client /// Base rest API client
/// </summary> /// </summary>
@ -15,4 +15,3 @@
/// </summary> /// </summary>
int TotalRequestsMade { get; set; } int TotalRequestsMade { get; set; }
} }
}

View File

@ -1,8 +1,8 @@
using System; using System;
using CryptoExchange.Net.Objects.Options; using CryptoExchange.Net.Objects.Options;
namespace CryptoExchange.Net.Interfaces namespace CryptoExchange.Net.Interfaces;
{
/// <summary> /// <summary>
/// Base class for rest API implementations /// Base class for rest API implementations
/// </summary> /// </summary>
@ -23,4 +23,3 @@ namespace CryptoExchange.Net.Interfaces
/// </summary> /// </summary>
string Exchange { get; } string Exchange { get; }
} }
}

View File

@ -1,10 +1,10 @@
using CryptoExchange.Net.Objects; using CryptoExchange.Net.Objects;
using CryptoExchange.Net.Objects.Options; using CryptoExchange.Net.Objects.Options;
using CryptoExchange.Net.Objects.Sockets; using CryptoExchange.Net.Objects.Sockets;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace CryptoExchange.Net.Interfaces namespace CryptoExchange.Net.Interfaces;
{
/// <summary> /// <summary>
/// Socket API client /// Socket API client
/// </summary> /// </summary>
@ -67,4 +67,3 @@ namespace CryptoExchange.Net.Interfaces
/// <returns></returns> /// <returns></returns>
Task<CallResult> PrepareConnectionsAsync(); Task<CallResult> PrepareConnectionsAsync();
} }
}

View File

@ -1,10 +1,10 @@
using System; using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using CryptoExchange.Net.Objects.Options; using CryptoExchange.Net.Objects.Options;
using CryptoExchange.Net.Objects.Sockets; using CryptoExchange.Net.Objects.Sockets;
namespace CryptoExchange.Net.Interfaces namespace CryptoExchange.Net.Interfaces;
{
/// <summary> /// <summary>
/// Base class for socket API implementations /// Base class for socket API implementations
/// </summary> /// </summary>
@ -55,4 +55,3 @@ namespace CryptoExchange.Net.Interfaces
/// <returns></returns> /// <returns></returns>
Task UnsubscribeAllAsync(); Task UnsubscribeAllAsync();
} }
}

View File

@ -1,11 +1,10 @@
using System; using System;
using System.Collections.Generic;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using CryptoExchange.Net.Objects; using CryptoExchange.Net.Objects;
namespace CryptoExchange.Net.Interfaces namespace CryptoExchange.Net.Interfaces;
{
/// <summary> /// <summary>
/// Interface for order book /// Interface for order book
/// </summary> /// </summary>
@ -128,4 +127,3 @@ namespace CryptoExchange.Net.Interfaces
/// <returns></returns> /// <returns></returns>
string ToString(int rows); string ToString(int rows);
} }
}

View File

@ -1,5 +1,5 @@
namespace CryptoExchange.Net.Interfaces namespace CryptoExchange.Net.Interfaces;
{
/// <summary> /// <summary>
/// Interface for order book entries /// Interface for order book entries
/// </summary> /// </summary>
@ -25,4 +25,3 @@
/// </summary> /// </summary>
long Sequence { get; set; } long Sequence { get; set; }
} }
}

View File

@ -1,11 +1,11 @@
using CryptoExchange.Net.Objects; using CryptoExchange.Net.Objects;
using System; using System;
using System.Net.WebSockets; using System.Net.WebSockets;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace CryptoExchange.Net.Interfaces namespace CryptoExchange.Net.Interfaces;
{
/// <summary> /// <summary>
/// Websocket connection interface /// Websocket connection interface
/// </summary> /// </summary>
@ -107,4 +107,3 @@ namespace CryptoExchange.Net.Interfaces
/// </summary> /// </summary>
void UpdateProxy(ApiProxy? proxy); void UpdateProxy(ApiProxy? proxy);
} }
}

View File

@ -1,8 +1,8 @@
using CryptoExchange.Net.Objects.Sockets; using CryptoExchange.Net.Objects.Sockets;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
namespace CryptoExchange.Net.Interfaces namespace CryptoExchange.Net.Interfaces;
{
/// <summary> /// <summary>
/// Websocket factory interface /// Websocket factory interface
/// </summary> /// </summary>
@ -16,4 +16,3 @@ namespace CryptoExchange.Net.Interfaces
/// <returns></returns> /// <returns></returns>
IWebsocket CreateWebsocket(ILogger logger, WebSocketParameters parameters); IWebsocket CreateWebsocket(ILogger logger, WebSocketParameters parameters);
} }
}

View File

@ -1,9 +1,5 @@
using System; namespace CryptoExchange.Net;
using System.Collections.Generic;
using System.Text;
namespace CryptoExchange.Net
{
/// <summary> /// <summary>
/// Helpers for client libraries /// Helpers for client libraries
/// </summary> /// </summary>
@ -44,4 +40,3 @@ namespace CryptoExchange.Net
return clientOrderId; return clientOrderId;
} }
} }
}

View File

@ -1,8 +1,8 @@
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using System; using System;
namespace CryptoExchange.Net.Logging.Extensions namespace CryptoExchange.Net.Logging.Extensions;
{
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
public static class CryptoExchangeWebSocketClientLoggingExtension public static class CryptoExchangeWebSocketClientLoggingExtension
{ {
@ -384,4 +384,3 @@ namespace CryptoExchange.Net.Logging.Extensions
_connectingCanceled(logger, socketId, null); _connectingCanceled(logger, socketId, null);
} }
} }
}

View File

@ -1,8 +1,8 @@
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using System; using System;
namespace CryptoExchange.Net.Logging.Extensions namespace CryptoExchange.Net.Logging.Extensions;
{
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
public static class RateLimitGateLoggingExtensions public static class RateLimitGateLoggingExtensions
{ {
@ -76,4 +76,3 @@ namespace CryptoExchange.Net.Logging.Extensions
_rateLimitAppliedRequest(logger, requestIdId, path, guard, limit, current, null); _rateLimitAppliedRequest(logger, requestIdId, path, guard, limit, current, null);
} }
} }
}

View File

@ -1,11 +1,11 @@
using CryptoExchange.Net.Objects; using CryptoExchange.Net.Objects;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using System; using System;
using System.Net; using System.Net;
using System.Net.Http; using System.Net.Http;
namespace CryptoExchange.Net.Logging.Extensions namespace CryptoExchange.Net.Logging.Extensions;
{
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
public static class RestApiClientLoggingExtensions public static class RestApiClientLoggingExtensions
{ {
@ -156,4 +156,3 @@ namespace CryptoExchange.Net.Logging.Extensions
_restApiCancellationRequested(logger, requestId, null); _restApiCancellationRequested(logger, requestId, null);
} }
} }
}

View File

@ -1,8 +1,8 @@
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using System; using System;
namespace CryptoExchange.Net.Logging.Extensions namespace CryptoExchange.Net.Logging.Extensions;
{
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
public static class SocketApiClientLoggingExtension public static class SocketApiClientLoggingExtension
{ {
@ -197,4 +197,3 @@ namespace CryptoExchange.Net.Logging.Extensions
_addingRetryAfterGuard(logger, retryAfter, null); _addingRetryAfterGuard(logger, retryAfter, null);
} }
} }
}

View File

@ -1,9 +1,9 @@
using System; using System;
using System.Net.WebSockets; using System.Net.WebSockets;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
namespace CryptoExchange.Net.Logging.Extensions namespace CryptoExchange.Net.Logging.Extensions;
{
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
public static class SocketConnectionLoggingExtension public static class SocketConnectionLoggingExtension
{ {
@ -346,4 +346,3 @@ namespace CryptoExchange.Net.Logging.Extensions
_sendingByteData(logger, socketId, requestId, length, null); _sendingByteData(logger, socketId, requestId, length, null);
} }
} }
}

View File

@ -1,9 +1,9 @@
using System; using System;
using CryptoExchange.Net.Objects; using CryptoExchange.Net.Objects;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
namespace CryptoExchange.Net.Logging.Extensions namespace CryptoExchange.Net.Logging.Extensions;
{
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
public static class SymbolOrderBookLoggingExtensions public static class SymbolOrderBookLoggingExtensions
@ -234,4 +234,3 @@ namespace CryptoExchange.Net.Logging.Extensions
_orderBookOutOfSyncChecksum(logger, api, symbol, null); _orderBookOutOfSyncChecksum(logger, api, symbol, null);
} }
} }
}

View File

@ -1,9 +1,9 @@
using System; using System;
using CryptoExchange.Net.Objects; using CryptoExchange.Net.Objects;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
namespace CryptoExchange.Net.Logging.Extensions namespace CryptoExchange.Net.Logging.Extensions;
{
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
public static class TrackerLoggingExtensions public static class TrackerLoggingExtensions
@ -288,4 +288,3 @@ namespace CryptoExchange.Net.Logging.Extensions
_tradeTrackerConnectionRestored(logger, symbol, null); _tradeTrackerConnectionRestored(logger, symbol, null);
} }
} }
}

View File

@ -1,5 +1,5 @@
namespace CryptoExchange.Net.Objects namespace CryptoExchange.Net.Objects;
{
/// <summary> /// <summary>
/// Proxy info /// Proxy info
/// </summary> /// </summary>
@ -39,4 +39,3 @@
Password = password; Password = password;
} }
} }
}

View File

@ -1,9 +1,5 @@
using System; namespace CryptoExchange.Net.Objects;
using System.Collections.Generic;
using System.Text;
namespace CryptoExchange.Net.Objects
{
/// <summary> /// <summary>
/// An alias used by the exchange for an asset commonly known by another name /// An alias used by the exchange for an asset commonly known by another name
/// </summary> /// </summary>
@ -27,4 +23,3 @@ namespace CryptoExchange.Net.Objects
CommonAssetName = commonName; CommonAssetName = commonName;
} }
} }
}

View File

@ -1,10 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text;
namespace CryptoExchange.Net.Objects namespace CryptoExchange.Net.Objects;
{
/// <summary> /// <summary>
/// Exchange configuration for asset aliases /// Exchange configuration for asset aliases
/// </summary> /// </summary>
@ -31,4 +28,3 @@ namespace CryptoExchange.Net.Objects
public string ExchangeToCommonName(string exchangeName) => !AutoConvertEnabled ? exchangeName : Aliases.SingleOrDefault(x => x.ExchangeAssetName == exchangeName)?.CommonAssetName ?? exchangeName; public string ExchangeToCommonName(string exchangeName) => !AutoConvertEnabled ? exchangeName : Aliases.SingleOrDefault(x => x.ExchangeAssetName == exchangeName)?.CommonAssetName ?? exchangeName;
} }
}

View File

@ -1,11 +1,11 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace CryptoExchange.Net.Objects namespace CryptoExchange.Net.Objects;
{
/// <summary> /// <summary>
/// Async auto reset based on Stephen Toub`s implementation /// Async auto reset based on Stephen Toub`s implementation
/// https://devblogs.microsoft.com/pfxteam/building-async-coordination-primitives-part-2-asyncautoresetevent/ /// https://devblogs.microsoft.com/pfxteam/building-async-coordination-primitives-part-2-asyncautoresetevent/
@ -106,10 +106,12 @@ namespace CryptoExchange.Net.Objects
toRelease.TrySetResult(true); toRelease.TrySetResult(true);
} }
else if (!_signaled) else if (!_signaled)
{
_signaled = true; _signaled = true;
} }
} }
} }
}
/// <summary> /// <summary>
/// Dispose /// Dispose
@ -119,4 +121,3 @@ namespace CryptoExchange.Net.Objects
_waits.Clear(); _waits.Clear();
} }
} }
}

View File

@ -1,10 +1,9 @@
using CryptoExchange.Net.Interfaces; using CryptoExchange.Net.Interfaces;
using System; using System;
namespace CryptoExchange.Net.Objects namespace CryptoExchange.Net.Objects;
{
internal class AuthTimeProvider : IAuthTimeProvider internal class AuthTimeProvider : IAuthTimeProvider
{ {
public DateTime GetTime() => DateTime.UtcNow; public DateTime GetTime() => DateTime.UtcNow;
} }
}

View File

@ -1,8 +1,8 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace CryptoExchange.Net.Objects namespace CryptoExchange.Net.Objects;
{
/// <summary> /// <summary>
/// Comparer for byte order /// Comparer for byte order
/// </summary> /// </summary>
@ -55,4 +55,3 @@ namespace CryptoExchange.Net.Objects
return x.Length < y.Length ? -1 : 1; return x.Length < y.Length ? -1 : 1;
} }
} }
}

View File

@ -1,4 +1,4 @@
using CryptoExchange.Net.SharedApis; using CryptoExchange.Net.SharedApis;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
@ -6,8 +6,8 @@ using System.Net;
using System.Net.Http; using System.Net.Http;
using System.Text; using System.Text;
namespace CryptoExchange.Net.Objects namespace CryptoExchange.Net.Objects;
{
/// <summary> /// <summary>
/// The result of an operation /// The result of an operation
/// </summary> /// </summary>
@ -140,12 +140,12 @@ namespace CryptoExchange.Net.Objects
/// <summary> /// <summary>
/// Copy the WebCallResult to a new data type /// Copy the WebCallResult to a new data type
/// </summary> /// </summary>
/// <typeparam name="K">The new type</typeparam> /// <typeparam name="TNew">The new type</typeparam>
/// <param name="data">The data of the new type</param> /// <param name="data">The data of the new type</param>
/// <returns></returns> /// <returns></returns>
public CallResult<K> As<K>([AllowNull] K data) public CallResult<TNew> As<TNew>([AllowNull] TNew data)
{ {
return new CallResult<K>(data, OriginalData, Error); return new CallResult<TNew>(data, OriginalData, Error);
} }
/// <summary> /// <summary>
@ -169,24 +169,24 @@ namespace CryptoExchange.Net.Objects
/// <summary> /// <summary>
/// Copy the CallResult to a new data type /// Copy the CallResult to a new data type
/// </summary> /// </summary>
/// <typeparam name="K">The new type</typeparam> /// <typeparam name="TNew">The new type</typeparam>
/// <param name="data">The data</param> /// <param name="data">The data</param>
/// <param name="error">The error returned</param> /// <param name="error">The error returned</param>
/// <returns></returns> /// <returns></returns>
public CallResult<K> AsErrorWithData<K>(Error error, K data) public CallResult<TNew> AsErrorWithData<TNew>(Error error, TNew data)
{ {
return new CallResult<K>(data, OriginalData, error); return new CallResult<TNew>(data, OriginalData, error);
} }
/// <summary> /// <summary>
/// Copy the WebCallResult to a new data type /// Copy the WebCallResult to a new data type
/// </summary> /// </summary>
/// <typeparam name="K">The new type</typeparam> /// <typeparam name="TNew">The new type</typeparam>
/// <param name="error">The error to return</param> /// <param name="error">The error to return</param>
/// <returns></returns> /// <returns></returns>
public CallResult<K> AsError<K>(Error error) public CallResult<TNew> AsError<TNew>(Error error)
{ {
return new CallResult<K>(default, OriginalData, error); return new CallResult<TNew>(default, OriginalData, error);
} }
/// <inheritdoc /> /// <inheritdoc />
@ -292,49 +292,49 @@ namespace CryptoExchange.Net.Objects
/// <summary> /// <summary>
/// Copy the WebCallResult to a new data type /// Copy the WebCallResult to a new data type
/// </summary> /// </summary>
/// <typeparam name="K">The new type</typeparam> /// <typeparam name="TNew">The new type</typeparam>
/// <param name="data">The data of the new type</param> /// <param name="data">The data of the new type</param>
/// <returns></returns> /// <returns></returns>
public WebCallResult<K> As<K>([AllowNull] K data) public WebCallResult<TNew> As<TNew>([AllowNull] TNew data)
{ {
return new WebCallResult<K>(ResponseStatusCode, ResponseHeaders, ResponseTime, 0, null, RequestId, RequestUrl, RequestBody, RequestMethod, RequestHeaders, ResultDataSource.Server, data, Error); return new WebCallResult<TNew>(ResponseStatusCode, ResponseHeaders, ResponseTime, 0, null, RequestId, RequestUrl, RequestBody, RequestMethod, RequestHeaders, ResultDataSource.Server, data, Error);
} }
/// <summary> /// <summary>
/// Copy the WebCallResult to an ExchangeWebResult of a new data type /// Copy the WebCallResult to an ExchangeWebResult of a new data type
/// </summary> /// </summary>
/// <typeparam name="K">The new type</typeparam> /// <typeparam name="TNew">The new type</typeparam>
/// <param name="exchange">The exchange</param> /// <param name="exchange">The exchange</param>
/// <param name="tradeMode">Trade mode the result applies to</param> /// <param name="tradeMode">Trade mode the result applies to</param>
/// <param name="data">The data</param> /// <param name="data">The data</param>
/// <returns></returns> /// <returns></returns>
public ExchangeWebResult<K> AsExchangeResult<K>(string exchange, TradingMode tradeMode, [AllowNull] K data) public ExchangeWebResult<TNew> AsExchangeResult<TNew>(string exchange, TradingMode tradeMode, [AllowNull] TNew data)
{ {
return new ExchangeWebResult<K>(exchange, tradeMode, this.As<K>(data)); return new ExchangeWebResult<TNew>(exchange, tradeMode, this.As<TNew>(data));
} }
/// <summary> /// <summary>
/// Copy the WebCallResult to an ExchangeWebResult of a new data type /// Copy the WebCallResult to an ExchangeWebResult of a new data type
/// </summary> /// </summary>
/// <typeparam name="K">The new type</typeparam> /// <typeparam name="TNew">The new type</typeparam>
/// <param name="exchange">The exchange</param> /// <param name="exchange">The exchange</param>
/// <param name="tradeModes">Trade modes the result applies to</param> /// <param name="tradeModes">Trade modes the result applies to</param>
/// <param name="data">The data</param> /// <param name="data">The data</param>
/// <returns></returns> /// <returns></returns>
public ExchangeWebResult<K> AsExchangeResult<K>(string exchange, TradingMode[]? tradeModes, [AllowNull] K data) public ExchangeWebResult<TNew> AsExchangeResult<TNew>(string exchange, TradingMode[]? tradeModes, [AllowNull] TNew data)
{ {
return new ExchangeWebResult<K>(exchange, tradeModes, this.As<K>(data)); return new ExchangeWebResult<TNew>(exchange, tradeModes, this.As<TNew>(data));
} }
/// <summary> /// <summary>
/// Copy the WebCallResult to a new data type /// Copy the WebCallResult to a new data type
/// </summary> /// </summary>
/// <typeparam name="K">The new type</typeparam> /// <typeparam name="TNew">The new type</typeparam>
/// <param name="error">The error returned</param> /// <param name="error">The error returned</param>
/// <returns></returns> /// <returns></returns>
public WebCallResult<K> AsError<K>(Error error) public WebCallResult<TNew> AsError<TNew>(Error error)
{ {
return new WebCallResult<K>(ResponseStatusCode, ResponseHeaders, ResponseTime, 0, null, RequestId, RequestUrl, RequestBody, RequestMethod, RequestHeaders, ResultDataSource.Server, default, error); return new WebCallResult<TNew>(ResponseStatusCode, ResponseHeaders, ResponseTime, 0, null, RequestId, RequestUrl, RequestBody, RequestMethod, RequestHeaders, ResultDataSource.Server, default, error);
} }
/// <inheritdoc /> /// <inheritdoc />
@ -470,35 +470,35 @@ namespace CryptoExchange.Net.Objects
/// <summary> /// <summary>
/// Copy the WebCallResult to a new data type /// Copy the WebCallResult to a new data type
/// </summary> /// </summary>
/// <typeparam name="K">The new type</typeparam> /// <typeparam name="TNew">The new type</typeparam>
/// <param name="data">The data of the new type</param> /// <param name="data">The data of the new type</param>
/// <returns></returns> /// <returns></returns>
public new WebCallResult<K> As<K>([AllowNull] K data) public new WebCallResult<TNew> As<TNew>([AllowNull] TNew data)
{ {
return new WebCallResult<K>(ResponseStatusCode, ResponseHeaders, ResponseTime, ResponseLength, OriginalData, RequestId, RequestUrl, RequestBody, RequestMethod, RequestHeaders, DataSource, data, Error); return new WebCallResult<TNew>(ResponseStatusCode, ResponseHeaders, ResponseTime, ResponseLength, OriginalData, RequestId, RequestUrl, RequestBody, RequestMethod, RequestHeaders, DataSource, data, Error);
} }
/// <summary> /// <summary>
/// Copy the WebCallResult to a new data type /// Copy the WebCallResult to a new data type
/// </summary> /// </summary>
/// <typeparam name="K">The new type</typeparam> /// <typeparam name="TNew">The new type</typeparam>
/// <param name="error">The error returned</param> /// <param name="error">The error returned</param>
/// <returns></returns> /// <returns></returns>
public new WebCallResult<K> AsError<K>(Error error) public new WebCallResult<TNew> AsError<TNew>(Error error)
{ {
return new WebCallResult<K>(ResponseStatusCode, ResponseHeaders, ResponseTime, ResponseLength, OriginalData, RequestId, RequestUrl, RequestBody, RequestMethod, RequestHeaders, DataSource, default, error); return new WebCallResult<TNew>(ResponseStatusCode, ResponseHeaders, ResponseTime, ResponseLength, OriginalData, RequestId, RequestUrl, RequestBody, RequestMethod, RequestHeaders, DataSource, default, error);
} }
/// <summary> /// <summary>
/// Copy the WebCallResult to a new data type /// Copy the WebCallResult to a new data type
/// </summary> /// </summary>
/// <typeparam name="K">The new type</typeparam> /// <typeparam name="TNew">The new type</typeparam>
/// <param name="data">The data</param> /// <param name="data">The data</param>
/// <param name="error">The error returned</param> /// <param name="error">The error returned</param>
/// <returns></returns> /// <returns></returns>
public new WebCallResult<K> AsErrorWithData<K>(Error error, K data) public new WebCallResult<TNew> AsErrorWithData<TNew>(Error error, TNew data)
{ {
return new WebCallResult<K>(ResponseStatusCode, ResponseHeaders, ResponseTime, ResponseLength, OriginalData, RequestId, RequestUrl, RequestBody, RequestMethod, RequestHeaders, DataSource, data, error); return new WebCallResult<TNew>(ResponseStatusCode, ResponseHeaders, ResponseTime, ResponseLength, OriginalData, RequestId, RequestUrl, RequestBody, RequestMethod, RequestHeaders, DataSource, data, error);
} }
/// <summary> /// <summary>
@ -526,41 +526,41 @@ namespace CryptoExchange.Net.Objects
/// <summary> /// <summary>
/// Copy the WebCallResult to an ExchangeWebResult of a new data type /// Copy the WebCallResult to an ExchangeWebResult of a new data type
/// </summary> /// </summary>
/// <typeparam name="K">The new type</typeparam> /// <typeparam name="TNew">The new type</typeparam>
/// <param name="exchange">The exchange</param> /// <param name="exchange">The exchange</param>
/// <param name="tradeMode">Trade mode the result applies to</param> /// <param name="tradeMode">Trade mode the result applies to</param>
/// <param name="data">Data</param> /// <param name="data">Data</param>
/// <param name="nextPageToken">Next page token</param> /// <param name="nextPageToken">Next page token</param>
/// <returns></returns> /// <returns></returns>
public ExchangeWebResult<K> AsExchangeResult<K>(string exchange, TradingMode tradeMode, [AllowNull] K data, INextPageToken? nextPageToken = null) public ExchangeWebResult<TNew> AsExchangeResult<TNew>(string exchange, TradingMode tradeMode, [AllowNull] TNew data, INextPageToken? nextPageToken = null)
{ {
return new ExchangeWebResult<K>(exchange, tradeMode, As<K>(data), nextPageToken); return new ExchangeWebResult<TNew>(exchange, tradeMode, As<TNew>(data), nextPageToken);
} }
/// <summary> /// <summary>
/// Copy the WebCallResult to an ExchangeWebResult of a new data type /// Copy the WebCallResult to an ExchangeWebResult of a new data type
/// </summary> /// </summary>
/// <typeparam name="K">The new type</typeparam> /// <typeparam name="TNew">The new type</typeparam>
/// <param name="exchange">The exchange</param> /// <param name="exchange">The exchange</param>
/// <param name="tradeModes">Trade modes the result applies to</param> /// <param name="tradeModes">Trade modes the result applies to</param>
/// <param name="data">Data</param> /// <param name="data">Data</param>
/// <param name="nextPageToken">Next page token</param> /// <param name="nextPageToken">Next page token</param>
/// <returns></returns> /// <returns></returns>
public ExchangeWebResult<K> AsExchangeResult<K>(string exchange, TradingMode[]? tradeModes, [AllowNull] K data, INextPageToken? nextPageToken = null) public ExchangeWebResult<TNew> AsExchangeResult<TNew>(string exchange, TradingMode[]? tradeModes, [AllowNull] TNew data, INextPageToken? nextPageToken = null)
{ {
return new ExchangeWebResult<K>(exchange, tradeModes, As<K>(data), nextPageToken); return new ExchangeWebResult<TNew>(exchange, tradeModes, As<TNew>(data), nextPageToken);
} }
/// <summary> /// <summary>
/// Copy the WebCallResult to an ExchangeWebResult with a specific error /// Copy the WebCallResult to an ExchangeWebResult with a specific error
/// </summary> /// </summary>
/// <typeparam name="K">The new type</typeparam> /// <typeparam name="TNew">The new type</typeparam>
/// <param name="exchange">The exchange</param> /// <param name="exchange">The exchange</param>
/// <param name="error">The error returned</param> /// <param name="error">The error returned</param>
/// <returns></returns> /// <returns></returns>
public ExchangeWebResult<K> AsExchangeError<K>(string exchange, Error error) public ExchangeWebResult<TNew> AsExchangeError<TNew>(string exchange, Error error)
{ {
return new ExchangeWebResult<K>(exchange, null, AsError<K>(error)); return new ExchangeWebResult<TNew>(exchange, null, AsError<TNew>(error));
} }
/// <summary> /// <summary>
@ -585,4 +585,3 @@ namespace CryptoExchange.Net.Objects
return sb.ToString(); return sb.ToString();
} }
} }
}

View File

@ -1,5 +1,5 @@
namespace CryptoExchange.Net.Objects namespace CryptoExchange.Net.Objects;
{
/// <summary> /// <summary>
/// Constants /// Constants
/// </summary> /// </summary>
@ -18,4 +18,3 @@
/// </summary> /// </summary>
public const string BodyPlaceHolderKey = "_BODY_"; public const string BodyPlaceHolderKey = "_BODY_";
} }
}

View File

@ -1,7 +1,5 @@
using CryptoExchange.Net.Attributes; namespace CryptoExchange.Net.Objects;
namespace CryptoExchange.Net.Objects
{
/// <summary> /// <summary>
/// What to do when a request would exceed the rate limit /// What to do when a request would exceed the rate limit
/// </summary> /// </summary>
@ -266,5 +264,3 @@ namespace CryptoExchange.Net.Objects
/// </summary> /// </summary>
Succeed Succeed
} }
}

View File

@ -1,14 +1,13 @@
using CryptoExchange.Net.Objects.Errors; using CryptoExchange.Net.Objects.Errors;
using System; using System;
namespace CryptoExchange.Net.Objects namespace CryptoExchange.Net.Objects;
{
/// <summary> /// <summary>
/// Base class for errors /// Base class for errors
/// </summary> /// </summary>
public abstract class Error public abstract class Error
{ {
private int? _code; private int? _code;
/// <summary> /// <summary>
/// The int error code the server returned; or the http status code int value if there was no error code.<br /> /// The int error code the server returned; or the http status code int value if there was no error code.<br />
@ -91,17 +90,17 @@ namespace CryptoExchange.Net.Objects
/// <summary> /// <summary>
/// Default error info /// Default error info
/// </summary> /// </summary>
protected static readonly ErrorInfo _errorInfo = new ErrorInfo(ErrorType.UnableToConnect, false, "Can't connect to the server"); protected static readonly ErrorInfo errorInfo = new ErrorInfo(ErrorType.UnableToConnect, false, "Can't connect to the server");
/// <summary> /// <summary>
/// ctor /// ctor
/// </summary> /// </summary>
public CantConnectError() : base(null, _errorInfo, null) { } public CantConnectError() : base(null, errorInfo, null) { }
/// <summary> /// <summary>
/// ctor /// ctor
/// </summary> /// </summary>
public CantConnectError(Exception? exception) : base(null, _errorInfo, exception) { } public CantConnectError(Exception? exception) : base(null, errorInfo, exception) { }
/// <summary> /// <summary>
/// ctor /// ctor
@ -117,12 +116,12 @@ namespace CryptoExchange.Net.Objects
/// <summary> /// <summary>
/// Default error info /// Default error info
/// </summary> /// </summary>
protected static readonly ErrorInfo _errorInfo = new ErrorInfo(ErrorType.MissingCredentials, false, "No credentials provided for private endpoint"); protected static readonly ErrorInfo errorInfo = new ErrorInfo(ErrorType.MissingCredentials, false, "No credentials provided for private endpoint");
/// <summary> /// <summary>
/// ctor /// ctor
/// </summary> /// </summary>
public NoApiCredentialsError() : base(null, _errorInfo, null) { } public NoApiCredentialsError() : base(null, errorInfo, null) { }
/// <summary> /// <summary>
/// ctor /// ctor
@ -161,12 +160,12 @@ namespace CryptoExchange.Net.Objects
/// <summary> /// <summary>
/// Default error info /// Default error info
/// </summary> /// </summary>
protected static readonly ErrorInfo _errorInfo = new ErrorInfo(ErrorType.NetworkError, true, "Failed to complete the request to the server due to a network error"); protected static readonly ErrorInfo errorInfo = new ErrorInfo(ErrorType.NetworkError, true, "Failed to complete the request to the server due to a network error");
/// <summary> /// <summary>
/// ctor /// ctor
/// </summary> /// </summary>
public WebError(string? message = null, Exception? exception = null) : base(null, _errorInfo with { Message = (message?.Length > 0 ? _errorInfo.Message + ": " + message : _errorInfo.Message) }, exception) { } public WebError(string? message = null, Exception? exception = null) : base(null, errorInfo with { Message = (message?.Length > 0 ? errorInfo.Message + ": " + message : errorInfo.Message) }, exception) { }
} }
/// <summary> /// <summary>
@ -177,12 +176,12 @@ namespace CryptoExchange.Net.Objects
/// <summary> /// <summary>
/// Default error info /// Default error info
/// </summary> /// </summary>
protected static readonly ErrorInfo _errorInfo = new ErrorInfo(ErrorType.Timeout, false, "Failed to receive a response from the server in time"); protected static readonly ErrorInfo errorInfo = new ErrorInfo(ErrorType.Timeout, false, "Failed to receive a response from the server in time");
/// <summary> /// <summary>
/// ctor /// ctor
/// </summary> /// </summary>
public TimeoutError(string? message = null, Exception? exception = null) : base(null, _errorInfo with { Message = (message?.Length > 0 ? _errorInfo.Message + ": " + message : _errorInfo.Message) }, exception) { } public TimeoutError(string? message = null, Exception? exception = null) : base(null, errorInfo with { Message = (message?.Length > 0 ? errorInfo.Message + ": " + message : errorInfo.Message) }, exception) { }
} }
/// <summary> /// <summary>
@ -193,12 +192,12 @@ namespace CryptoExchange.Net.Objects
/// <summary> /// <summary>
/// Default error info /// Default error info
/// </summary> /// </summary>
protected static readonly ErrorInfo _errorInfo = new ErrorInfo(ErrorType.DeserializationFailed, false, "Failed to deserialize data"); protected static readonly ErrorInfo errorInfo = new ErrorInfo(ErrorType.DeserializationFailed, false, "Failed to deserialize data");
/// <summary> /// <summary>
/// ctor /// ctor
/// </summary> /// </summary>
public DeserializeError(string? message = null, Exception? exception = null) : base(null, _errorInfo with { Message = (message?.Length > 0 ? _errorInfo.Message + ": " + message : _errorInfo.Message) }, exception) { } public DeserializeError(string? message = null, Exception? exception = null) : base(null, errorInfo with { Message = (message?.Length > 0 ? errorInfo.Message + ": " + message : errorInfo.Message) }, exception) { }
} }
/// <summary> /// <summary>
@ -209,21 +208,21 @@ namespace CryptoExchange.Net.Objects
/// <summary> /// <summary>
/// Default error info for missing parameter /// Default error info for missing parameter
/// </summary> /// </summary>
protected static readonly ErrorInfo _missingInfo = new ErrorInfo(ErrorType.MissingParameter, false, "Missing parameter"); protected static readonly ErrorInfo missingInfo = new ErrorInfo(ErrorType.MissingParameter, false, "Missing parameter");
/// <summary> /// <summary>
/// Default error info for invalid parameter /// Default error info for invalid parameter
/// </summary> /// </summary>
protected static readonly ErrorInfo _invalidInfo = new ErrorInfo(ErrorType.InvalidParameter, false, "Invalid parameter"); protected static readonly ErrorInfo invalidInfo = new ErrorInfo(ErrorType.InvalidParameter, false, "Invalid parameter");
/// <summary> /// <summary>
/// ctor /// ctor
/// </summary> /// </summary>
public static ArgumentError Missing(string parameterName, string? message = null) => new ArgumentError(_missingInfo with { Message = message == null ? $"{_missingInfo.Message} '{parameterName}'" : $"{_missingInfo.Message} '{parameterName}': {message}" }, null); public static ArgumentError Missing(string parameterName, string? message = null) => new ArgumentError(missingInfo with { Message = message == null ? $"{missingInfo.Message} '{parameterName}'" : $"{missingInfo.Message} '{parameterName}': {message}" }, null);
/// <summary> /// <summary>
/// ctor /// ctor
/// </summary> /// </summary>
public static ArgumentError Invalid(string parameterName, string message) => new ArgumentError(_invalidInfo with { Message = $"{_invalidInfo.Message} '{parameterName}': {message}" }, null); public static ArgumentError Invalid(string parameterName, string message) => new ArgumentError(invalidInfo with { Message = $"{invalidInfo.Message} '{parameterName}': {message}" }, null);
/// <summary> /// <summary>
/// ctor /// ctor
@ -255,12 +254,12 @@ namespace CryptoExchange.Net.Objects
/// <summary> /// <summary>
/// Default error info /// Default error info
/// </summary> /// </summary>
protected static readonly ErrorInfo _errorInfo = new ErrorInfo(ErrorType.RateLimitRequest, false, "Client rate limit exceeded"); protected static readonly ErrorInfo errorInfo = new ErrorInfo(ErrorType.RateLimitRequest, false, "Client rate limit exceeded");
/// <summary> /// <summary>
/// ctor /// ctor
/// </summary> /// </summary>
public ClientRateLimitError(string? message = null, Exception? exception = null) : base(_errorInfo with { Message = (message?.Length > 0 ? _errorInfo.Message + ": " + message : _errorInfo.Message) }, exception) { } public ClientRateLimitError(string? message = null, Exception? exception = null) : base(errorInfo with { Message = (message?.Length > 0 ? errorInfo.Message + ": " + message : errorInfo.Message) }, exception) { }
/// <summary> /// <summary>
/// ctor /// ctor
@ -276,12 +275,12 @@ namespace CryptoExchange.Net.Objects
/// <summary> /// <summary>
/// Default error info /// Default error info
/// </summary> /// </summary>
protected static readonly ErrorInfo _errorInfo = new ErrorInfo(ErrorType.RateLimitRequest, false, "Server rate limit exceeded"); protected static readonly ErrorInfo errorInfo = new ErrorInfo(ErrorType.RateLimitRequest, false, "Server rate limit exceeded");
/// <summary> /// <summary>
/// ctor /// ctor
/// </summary> /// </summary>
public ServerRateLimitError(string? message = null, Exception? exception = null) : base(_errorInfo with { Message = (message?.Length > 0 ? _errorInfo.Message + ": " + message : _errorInfo.Message) }, exception) { } public ServerRateLimitError(string? message = null, Exception? exception = null) : base(errorInfo with { Message = (message?.Length > 0 ? errorInfo.Message + ": " + message : errorInfo.Message) }, exception) { }
/// <summary> /// <summary>
/// ctor /// ctor
@ -297,12 +296,12 @@ namespace CryptoExchange.Net.Objects
/// <summary> /// <summary>
/// Default error info /// Default error info
/// </summary> /// </summary>
protected static readonly ErrorInfo _errorInfo = new ErrorInfo(ErrorType.CancellationRequested, false, "Cancellation requested"); protected static readonly ErrorInfo errorInfo = new ErrorInfo(ErrorType.CancellationRequested, false, "Cancellation requested");
/// <summary> /// <summary>
/// ctor /// ctor
/// </summary> /// </summary>
public CancellationRequestedError(Exception? exception = null) : base(null, _errorInfo, null) { } public CancellationRequestedError(Exception? exception = null) : base(null, errorInfo, null) { }
/// <summary> /// <summary>
/// ctor /// ctor
@ -318,16 +317,15 @@ namespace CryptoExchange.Net.Objects
/// <summary> /// <summary>
/// Default error info /// Default error info
/// </summary> /// </summary>
protected static readonly ErrorInfo _errorInfo = new ErrorInfo(ErrorType.InvalidOperation, false, "Operation invalid"); protected static readonly ErrorInfo errorInfo = new ErrorInfo(ErrorType.InvalidOperation, false, "Operation invalid");
/// <summary> /// <summary>
/// ctor /// ctor
/// </summary> /// </summary>
public InvalidOperationError(string message) : base(null, _errorInfo with { Message = message }, null) { } public InvalidOperationError(string message) : base(null, errorInfo with { Message = message }, null) { }
/// <summary> /// <summary>
/// ctor /// ctor
/// </summary> /// </summary>
protected InvalidOperationError(ErrorInfo info, Exception? exception) : base(null, info, exception) { } protected InvalidOperationError(ErrorInfo info, Exception? exception) : base(null, info, exception) { }
} }
}

View File

@ -1,9 +1,7 @@
using System; using System;
using System.Collections.Generic;
using System.Text; namespace CryptoExchange.Net.Objects.Errors;
namespace CryptoExchange.Net.Objects.Errors
{
/// <summary> /// <summary>
/// Error evaluator /// Error evaluator
/// </summary> /// </summary>
@ -37,4 +35,3 @@ namespace CryptoExchange.Net.Objects.Errors
ErrorTypeEvaluator = errorTypeEvaluator; ErrorTypeEvaluator = errorTypeEvaluator;
} }
} }
}

View File

@ -1,7 +1,5 @@
using System; namespace CryptoExchange.Net.Objects.Errors;
namespace CryptoExchange.Net.Objects.Errors
{
/// <summary> /// <summary>
/// Error info /// Error info
/// </summary> /// </summary>
@ -55,4 +53,3 @@ namespace CryptoExchange.Net.Objects.Errors
ErrorDescription = description; ErrorDescription = description;
} }
} }
}

View File

@ -1,10 +1,8 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CryptoExchange.Net.Objects.Errors namespace CryptoExchange.Net.Objects.Errors;
{
/// <summary> /// <summary>
/// Error mapping collection /// Error mapping collection
/// </summary> /// </summary>
@ -20,7 +18,7 @@ namespace CryptoExchange.Net.Objects.Errors
{ {
foreach (var item in errorMappings) foreach (var item in errorMappings)
{ {
if (!item.ErrorCodes.Any()) if (item.ErrorCodes.Length == 0)
throw new Exception("Error codes can't be null in error mapping"); throw new Exception("Error codes can't be null in error mapping");
foreach(var code in item.ErrorCodes!) foreach(var code in item.ErrorCodes!)
@ -51,4 +49,3 @@ namespace CryptoExchange.Net.Objects.Errors
return ErrorInfo.Unknown with { Message = message }; return ErrorInfo.Unknown with { Message = message };
} }
} }
}

View File

@ -1,9 +1,5 @@
using System; namespace CryptoExchange.Net.Objects.Errors;
using System.Collections.Generic;
using System.Text;
namespace CryptoExchange.Net.Objects.Errors
{
/// <summary> /// <summary>
/// Type of error /// Type of error
/// </summary> /// </summary>
@ -159,4 +155,3 @@ namespace CryptoExchange.Net.Objects.Errors
#endregion #endregion
} }
}

View File

@ -1,7 +1,7 @@
using CryptoExchange.Net.Authentication; using CryptoExchange.Net.Authentication;
namespace CryptoExchange.Net.Objects.Options;
namespace CryptoExchange.Net.Objects.Options
{
/// <summary> /// <summary>
/// Options for API usage /// Options for API usage
/// </summary> /// </summary>
@ -17,4 +17,3 @@ namespace CryptoExchange.Net.Objects.Options
/// </summary> /// </summary>
public ApiCredentials? ApiCredentials { get; set; } public ApiCredentials? ApiCredentials { get; set; }
} }
}

View File

@ -1,8 +1,8 @@
using CryptoExchange.Net.Authentication; using CryptoExchange.Net.Authentication;
using System; using System;
namespace CryptoExchange.Net.Objects.Options namespace CryptoExchange.Net.Objects.Options;
{
/// <summary> /// <summary>
/// Exchange options /// Exchange options
/// </summary> /// </summary>
@ -16,7 +16,7 @@ namespace CryptoExchange.Net.Objects.Options
/// <summary> /// <summary>
/// If true, the CallResult and DataEvent objects will also include the originally received json data in the OriginalData property /// If true, the CallResult and DataEvent objects will also include the originally received json data in the OriginalData property
/// </summary> /// </summary>
public bool OutputOriginalData { get; set; } = false; public bool OutputOriginalData { get; set; }
/// <summary> /// <summary>
/// The max time a request is allowed to take /// The max time a request is allowed to take
@ -43,4 +43,3 @@ namespace CryptoExchange.Net.Objects.Options
return $"RequestTimeout: {RequestTimeout}, Proxy: {(Proxy == null ? "-" : "set")}, ApiCredentials: {(ApiCredentials == null ? "-" : "set")}"; return $"RequestTimeout: {RequestTimeout}, Proxy: {(Proxy == null ? "-" : "set")}, ApiCredentials: {(ApiCredentials == null ? "-" : "set")}";
} }
} }
}

View File

@ -1,8 +1,8 @@
using CryptoExchange.Net.Authentication; using CryptoExchange.Net.Authentication;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
namespace CryptoExchange.Net.Objects.Options namespace CryptoExchange.Net.Objects.Options;
{
/// <summary> /// <summary>
/// Library options /// Library options
/// </summary> /// </summary>
@ -55,4 +55,3 @@ namespace CryptoExchange.Net.Objects.Options
return targetOptions; return targetOptions;
} }
} }
}

View File

@ -1,5 +1,5 @@
namespace CryptoExchange.Net.Objects.Options namespace CryptoExchange.Net.Objects.Options;
{
/// <summary> /// <summary>
/// Base for order book options /// Base for order book options
/// </summary> /// </summary>
@ -23,4 +23,3 @@
}; };
} }
} }
}

View File

@ -1,8 +1,8 @@
using CryptoExchange.Net.Authentication; using CryptoExchange.Net.Authentication;
using System; using System;
namespace CryptoExchange.Net.Objects.Options namespace CryptoExchange.Net.Objects.Options;
{
/// <summary> /// <summary>
/// Http api options /// Http api options
/// </summary> /// </summary>
@ -46,4 +46,3 @@ namespace CryptoExchange.Net.Objects.Options
set => base.ApiCredentials = value; set => base.ApiCredentials = value;
} }
} }
}

View File

@ -1,8 +1,8 @@
using CryptoExchange.Net.Authentication; using CryptoExchange.Net.Authentication;
using System; using System;
namespace CryptoExchange.Net.Objects.Options namespace CryptoExchange.Net.Objects.Options;
{
/// <summary> /// <summary>
/// Options for a rest exchange client /// Options for a rest exchange client
/// </summary> /// </summary>
@ -21,7 +21,7 @@ namespace CryptoExchange.Net.Objects.Options
/// <summary> /// <summary>
/// Whether caching is enabled. Caching will only be applied to GET http requests. The lifetime of cached results can be determined by the `CachingMaxAge` option /// Whether caching is enabled. Caching will only be applied to GET http requests. The lifetime of cached results can be determined by the `CachingMaxAge` option
/// </summary> /// </summary>
public bool CachingEnabled { get; set; } = false; public bool CachingEnabled { get; set; }
/// <summary> /// <summary>
/// The max age of a cached entry, only used when the `CachingEnabled` options is set to true. When a cached entry is older than the max age it will be discarded and a new server request will be done /// The max age of a cached entry, only used when the `CachingEnabled` options is set to true. When a cached entry is older than the max age it will be discarded and a new server request will be done
@ -88,4 +88,3 @@ namespace CryptoExchange.Net.Objects.Options
set => base.ApiCredentials = value; set => base.ApiCredentials = value;
} }
} }
}

Some files were not shown because too many files have changed in this diff Show More