Skip to content

Commit

Permalink
Added cached lib versions properties
Browse files Browse the repository at this point in the history
  • Loading branch information
JKorf committed Oct 4, 2024
1 parent 6cb6cd6 commit 1f31e4a
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion CryptoExchange.Net/Clients/BaseClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,28 @@ namespace CryptoExchange.Net.Clients
/// </summary>
public abstract class BaseClient : IDisposable
{
/// <summary>
/// Version of the CryptoExchange.Net base library
/// </summary>
public Version CryptoExchangeLibVersion { get; } = typeof(BaseClient).Assembly.GetName().Version;

/// <summary>
/// Version of the client implementation
/// </summary>
public Version ExchangeLibVersion
{
get
{
lock(_versionLock)
{
if (_exchangeVersion == null)
_exchangeVersion = GetType().Assembly.GetName().Version;

return _exchangeVersion;
}
}
}

/// <summary>
/// The name of the API the client is for
/// </summary>
Expand All @@ -27,6 +49,9 @@ public abstract class BaseClient : IDisposable
/// </summary>
protected internal ILogger _logger;

private object _versionLock = new object();
private Version _exchangeVersion;

/// <summary>
/// Provided client options
/// </summary>
Expand Down Expand Up @@ -57,7 +82,7 @@ protected virtual void Initialize(ExchangeOptions options)
throw new ArgumentNullException(nameof(options));

ClientOptions = options;
_logger.Log(LogLevel.Trace, $"Client configuration: {options}, CryptoExchange.Net: v{typeof(BaseClient).Assembly.GetName().Version}, {Exchange}.Net: v{GetType().Assembly.GetName().Version}");
_logger.Log(LogLevel.Trace, $"Client configuration: {options}, CryptoExchange.Net: v{CryptoExchangeLibVersion}, {Exchange}.Net: v{ExchangeLibVersion}");
}

/// <summary>
Expand Down

0 comments on commit 1f31e4a

Please sign in to comment.