public static void RaiseAskForStockSubscriptionEvent(string tradingSymbol, StockSubscribeMode mode, bool isSubscribe) { if (AskForStockSubscriptionEvent != null) { AskForStockSubscriptionEvent(tradingSymbol, mode, isSubscribe); } }
private void Events_AskForStockSubscriptionEvent(string tradingSymbol, StockSubscribeMode mode, bool isSubscribe) { switch (mode) { case StockSubscribeMode.LTP: if (isSubscribe) { if (!_configuredStocksForLTP.Any(s => s.Equals(tradingSymbol))) { _configuredStocksForLTP.Add(tradingSymbol); } } else { var stock = _configuredStocksForLTP.FirstOrDefault(s => s.Equals(tradingSymbol)); if (stock != null) { _configuredStocksForLTP = new ConcurrentBag <string>(_configuredStocksForLTP.Except(new[] { tradingSymbol })); if (_cachedStockLtp.ContainsKey(tradingSymbol)) { _cachedStockLtp.Remove(tradingSymbol); } } } break; } StartStopLTP(_configuredStocksForLTP.Any()); }