diff --git a/CryptoExchange.Net/Objects/Options/LibraryOptions.cs b/CryptoExchange.Net/Objects/Options/LibraryOptions.cs new file mode 100644 index 0000000..1c9400f --- /dev/null +++ b/CryptoExchange.Net/Objects/Options/LibraryOptions.cs @@ -0,0 +1,58 @@ +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 = ApiCredentials; + targetOptions.Environment = Environment; + targetOptions.SocketClientLifeTime = SocketClientLifeTime; + targetOptions.Rest = Rest.Set(targetOptions.Rest); + targetOptions.Socket = Socket.Set(targetOptions.Socket); + + return targetOptions; + } + } +}