Esempio n. 1
0
        /// <summary>
        /// Add the ICoinExClient and ICoinExSocketClient 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 ICoinExSocketClient for the service collection. Defaults to Scoped.</param>
        /// <returns></returns>
        public static IServiceCollection AddCoinEx(
            this IServiceCollection services,
            Action <CoinExClientOptions, CoinExSocketClientOptions>?defaultOptionsCallback = null,
            ServiceLifetime?socketClientLifeTime = null)
        {
            if (defaultOptionsCallback != null)
            {
                var options       = new CoinExClientOptions();
                var socketOptions = new CoinExSocketClientOptions();
                defaultOptionsCallback?.Invoke(options, socketOptions);

                CoinExClient.SetDefaultOptions(options);
                CoinExSocketClient.SetDefaultOptions(socketOptions);
            }

            services.AddTransient <ICoinExClient, CoinExClient>();
            if (socketClientLifeTime == null)
            {
                services.AddScoped <ICoinExSocketClient, CoinExSocketClient>();
            }
            else
            {
                services.Add(new ServiceDescriptor(typeof(ICoinExSocketClient), typeof(CoinExSocketClient), socketClientLifeTime.Value));
            }
            return(services);
        }
Esempio n. 2
0
 /// <summary>
 /// Create a new order book instance
 /// </summary>
 /// <param name="symbol">The symbol of the order book</param>
 /// <param name="options">The options for the order book</param>
 public CoinExSymbolOrderBook(string symbol, CoinExOrderBookOptions?options = null) : base(symbol, options ?? new CoinExOrderBookOptions())
 {
     symbol.ValidateCoinExSymbol();
     socketClient = new CoinExSocketClient();
     Levels       = 20;
 }
Esempio n. 3
0
 /// <summary>
 /// Create a new order book instance
 /// </summary>
 /// <param name="symbol">The symbol of the order book</param>
 /// <param name="options">The options for the order book</param>
 public CoinExSymbolOrderBook(string symbol, CoinExOrderBookOptions options = null) : base(symbol, options ?? new CoinExOrderBookOptions())
 {
     socketClient = new CoinExSocketClient();
 }