/// <summary> /// Add the IBitfinexClient and IBitfinexSocketClient to the sevice collection so they can be injected /// </summary> /// <param name="services">The service collection</param> /// <param name="defaultOptionsCallback">Set default options for the client</param> /// <param name="socketClientLifeTime">The lifetime of the IBitfinexSocketClient for the service collection. Defaults to Scoped.</param> /// <returns></returns> public static IServiceCollection AddBitfinex( this IServiceCollection services, Action <BitfinexClientOptions, BitfinexSocketClientOptions>?defaultOptionsCallback = null, ServiceLifetime?socketClientLifeTime = null) { if (defaultOptionsCallback != null) { var options = new BitfinexClientOptions(); var socketOptions = new BitfinexSocketClientOptions(); defaultOptionsCallback?.Invoke(options, socketOptions); BitfinexClient.SetDefaultOptions(options); BitfinexSocketClient.SetDefaultOptions(socketOptions); } services.AddTransient <IBitfinexClient, BitfinexClient>(); if (socketClientLifeTime == null) { services.AddScoped <IBitfinexSocketClient, BitfinexSocketClient>(); } else { services.Add(new ServiceDescriptor(typeof(IBitfinexSocketClient), typeof(BitfinexSocketClient), socketClientLifeTime.Value)); } return(services); }
private void Configure(BitfinexClientOptions options) { base.Configure(options); baseAddress = options.BaseAddress; }
/// <summary> /// Create a new instance of BinanceClient using provided options /// </summary> /// <param name="options">The options to use for this client</param> public BitfinexClient(BitfinexClientOptions options) : base(options, options.ApiCredentials == null ? null : new BitfinexAuthenticationProvider(options.ApiCredentials)) { Configure(options); }
/// <summary> /// Sets the default options to use for new clients /// </summary> /// <param name="options">The options to use for new clients</param> public static void SetDefaultOptions(BitfinexClientOptions options) { defaultOptions = options; }