using CryptoExchange.Net.Authentication;
using Microsoft.Extensions.DependencyInjection;
namespace CryptoExchange.Net.Objects.Options
{
///
/// Library options
///
///
///
///
///
public class LibraryOptions
where TRestOptions: RestExchangeOptions, new()
where TSocketOptions: SocketExchangeOptions, new()
where TApiCredentials: ApiCredentials
where TEnvironment: TradeEnvironment
{
///
/// Rest client options
///
public TRestOptions Rest { get; set; } = new TRestOptions();
///
/// Socket client options
///
public TSocketOptions Socket { get; set; } = new TSocketOptions();
///
/// Trade environment. Contains info about URL's to use to connect to the API.
///
public TEnvironment? Environment { get; set; }
///
/// The api credentials used for signing requests.
///
public TApiCredentials? ApiCredentials { get; set; }
///
/// The DI service lifetime for the socket client
///
public ServiceLifetime? SocketClientLifeTime { get; set; }
///
/// Copy values from these options to the target options
///
public T Set(T targetOptions) where T: LibraryOptions
{
targetOptions.ApiCredentials = (TApiCredentials?)ApiCredentials?.Copy();
targetOptions.Environment = Environment;
targetOptions.SocketClientLifeTime = SocketClientLifeTime;
targetOptions.Rest = Rest.Set(targetOptions.Rest);
targetOptions.Socket = Socket.Set(targetOptions.Socket);
return targetOptions;
}
}
}