1
0
mirror of https://github.com/JKorf/CryptoExchange.Net synced 2025-06-07 16:06:15 +00:00

Small changes for options

This commit is contained in:
Jan Korf 2022-02-23 22:04:43 +01:00
parent c792bc25b6
commit 0c6e74911d
3 changed files with 8 additions and 5 deletions

View File

@ -70,7 +70,7 @@ namespace CryptoExchange.Net.Authentication
public virtual ApiCredentials Copy()
{
if (PrivateKey == null)
return new ApiCredentials(Key!.GetString(), Secret!.GetString());
return new ApiCredentials(Key!, Secret!);
else
return new ApiCredentials(PrivateKey!.Copy());
}

View File

@ -12,6 +12,7 @@ namespace CryptoExchange.Net
private ApiCredentials? _apiCredentials;
private AuthenticationProvider? _authenticationProvider;
private bool _created;
private bool _disposing;
/// <summary>
/// The authentication provider for this API client. (null if no credentials are set)
@ -20,7 +21,7 @@ namespace CryptoExchange.Net
{
get
{
if (!_created && _apiCredentials != null)
if (!_created && !_disposing && _apiCredentials != null)
{
_authenticationProvider = CreateAuthenticationProvider(_apiCredentials);
_created = true;
@ -62,7 +63,7 @@ namespace CryptoExchange.Net
/// <inheritdoc />
public void SetApiCredentials(ApiCredentials credentials)
{
_apiCredentials = credentials;
_apiCredentials = credentials?.Copy();
_created = false;
_authenticationProvider = null;
}
@ -72,6 +73,8 @@ namespace CryptoExchange.Net
/// </summary>
public void Dispose()
{
_disposing = true;
_apiCredentials?.Dispose();
AuthenticationProvider?.Credentials?.Dispose();
}
}

View File

@ -260,7 +260,7 @@ namespace CryptoExchange.Net.Objects
/// </summary>
/// <param name="baseOptions">Copy values for the provided options</param>
#pragma warning disable 8618 // Will always get filled by the provided options
public ApiClientOptions(ApiClientOptions baseOptions, RestApiClientOptions? newValues)
public ApiClientOptions(ApiClientOptions baseOptions, ApiClientOptions? newValues)
{
BaseAddress = newValues?.BaseAddress ?? baseOptions.BaseAddress;
ApiCredentials = newValues?.ApiCredentials?.Copy() ?? baseOptions.ApiCredentials?.Copy();
@ -318,7 +318,7 @@ namespace CryptoExchange.Net.Objects
/// ctor
/// </summary>
/// <param name="baseOn">Copy values for the provided options</param>
public RestApiClientOptions(RestApiClientOptions baseOn, RestApiClientOptions newValues): base(baseOn, newValues)
public RestApiClientOptions(RestApiClientOptions baseOn, RestApiClientOptions? newValues): base(baseOn, newValues)
{
RateLimitingBehaviour = newValues?.RateLimitingBehaviour ?? baseOn.RateLimitingBehaviour;
AutoTimestamp = newValues?.AutoTimestamp ?? baseOn.AutoTimestamp;