18 using System.Collections;
19 using System.Collections.Generic;
20 using System.Collections.Specialized;
50 _timeProvider = timeProvider;
51 _marketHoursDatabase = marketHoursDatabase;
62 var enumerator = (IEnumerator<BaseData>) _universe.GetTriggerTimes(request.
StartTimeUtc, request.
EndTimeUtc, _marketHoursDatabase)
69 enumerator =
new InjectionEnumerator(enumerator);
72 universe.CollectionChanged += (sender, args) =>
79 if (args.Action == NotifyCollectionChangedAction.Add)
81 items = args.NewItems;
82 time = _timeProvider.GetUtcNow().AddTicks(1);
84 else if (args.Action == NotifyCollectionChangedAction.Remove)
86 items = args.OldItems;
87 time = _timeProvider.GetUtcNow();
92 time = DateTime.MinValue;
96 if (items ==
null || time == DateTime.MinValue)
return;
98 var symbol = items.OfType<
Symbol>().FirstOrDefault();
100 if(symbol ==
null)
return;
106 ((InjectionEnumerator) enumerator).InjectDataPoint(collection);
113 private class InjectionEnumerator : IEnumerator<BaseData>
115 private volatile bool _wasInjected;
116 private readonly IEnumerator<BaseData> _underlyingEnumerator;
118 public BaseData Current {
get;
private set; }
120 object IEnumerator.Current => Current;
122 public InjectionEnumerator(IEnumerator<BaseData> underlyingEnumerator)
124 _underlyingEnumerator = underlyingEnumerator;
127 public void InjectDataPoint(
BaseData baseData)
130 lock (_underlyingEnumerator)
137 public void Dispose()
139 _underlyingEnumerator.Dispose();
142 public bool MoveNext()
144 lock (_underlyingEnumerator)
148 _wasInjected =
false;
151 _underlyingEnumerator.MoveNext();
152 Current = _underlyingEnumerator.Current;
159 _underlyingEnumerator.Reset();