16 using System.Collections.Generic;
32 private readonly HashSet<SubscriptionDataConfig> _toBeAddedCurrencySubscriptionDataConfigs;
33 private readonly HashSet<SubscriptionDataConfig> _addedCurrencySubscriptionDataConfigs;
34 private bool _ensureCurrencyDataFeeds;
35 private bool _pendingSubscriptionDataConfigs;
37 private readonly
Resolution _defaultResolution;
56 cashBook.
Updated += (sender, args) =>
60 _ensureCurrencyDataFeeds =
true;
64 _defaultResolution = defaultResolution;
65 _pendingSubscriptionDataConfigs =
false;
66 _securityManager = securityManager;
67 _subscriptionManager = subscriptionManager;
68 _securityService = securityService;
70 _addedCurrencySubscriptionDataConfigs =
new HashSet<SubscriptionDataConfig>();
71 _toBeAddedCurrencySubscriptionDataConfigs =
new HashSet<SubscriptionDataConfig>();
87 var currencyDataFeed = _addedCurrencySubscriptionDataConfigs
88 .FirstOrDefault(x => x.Symbol == addedSymbol);
89 if (currencyDataFeed !=
null)
91 return currencyDataFeed;
103 if (_ensureCurrencyDataFeeds)
108 return _pendingSubscriptionDataConfigs;
117 var result =
new List<SubscriptionDataConfig>();
118 if (_pendingSubscriptionDataConfigs)
120 foreach (var subscriptionDataConfig
in _toBeAddedCurrencySubscriptionDataConfigs)
122 _addedCurrencySubscriptionDataConfigs.Add(subscriptionDataConfig);
123 result.Add(subscriptionDataConfig);
125 _toBeAddedCurrencySubscriptionDataConfigs.Clear();
126 _pendingSubscriptionDataConfigs =
false;
136 _ensureCurrencyDataFeeds =
false;
138 _toBeAddedCurrencySubscriptionDataConfigs.RemoveWhere(
139 config => securityChanges.
AddedSecurities.Any(x => x.Symbol == config.Symbol));
141 var newConfigs = _cashBook.EnsureCurrencyDataFeeds(
143 _subscriptionManager,
148 foreach (var config
in newConfigs)
150 _toBeAddedCurrencySubscriptionDataConfigs.Add(config);
152 _pendingSubscriptionDataConfigs = _toBeAddedCurrencySubscriptionDataConfigs.Any();