/// <summary> /// Before using this controller, call Start(). /// </summary> public CrypnosticController( CrypnosticConfig config) { log.Trace(nameof(CrypnosticController)); Debug.Assert(config != null); Debug.Assert(config.supportedExchangeList.Length > 0); //Debug.Assert(instance == null); // won't be true if you stop then start. instance = this; coinMarketCap = new CoinMarketCapAPI(); foreach (KeyValuePair <string, string> aliasToName in config.coinAliasToName) { AddCoinAlias(aliasToName.Value, aliasToName.Key); } foreach (string blacklistedCoin in config.blacklistedCoins) { Debug.Assert(fullNameLowerToCoin.ContainsKey(blacklistedCoin.ToLowerInvariant()) == false); blacklistedFullNameLowerList.Add(blacklistedCoin.ToLowerInvariant()); } exchangeList = new Exchange[config.supportedExchangeList.Length]; for (int i = 0; i < config.supportedExchangeList.Length; i++) { ExchangeName name = config.supportedExchangeList[i]; Exchange exchange = Exchange.LoadExchange(name); exchangeList[i] = exchange; } }
/// <summary> /// Call this when exiting the application /// or any other time you want the auto-refresh to stop. /// </summary> public void Stop() { log.Trace(nameof(Stop)); Debug.Assert(instance == this); cancellationTokenSource.Cancel(); instance = null; }