21 using System.Collections;
23 using System.Collections.Generic;
32 private readonly List<IEnumerator<BaseData>> _enumerators;
33 private readonly
bool _skipDuplicateEndTimes;
34 private DateTime? _lastEnumeratorEndTime;
35 private int _currentIndex;
49 object IEnumerator.Current =>
Current;
58 params IEnumerator<BaseData>[] enumerators
62 _skipDuplicateEndTimes = skipDuplicateEndTimes;
63 _enumerators = enumerators.Where(enumerator => enumerator !=
null).ToList();
72 for (; _currentIndex < _enumerators.Count; _currentIndex++)
74 var enumerator = _enumerators[_currentIndex];
75 while (enumerator.MoveNext())
77 if (enumerator.Current ==
null && (_currentIndex < _enumerators.Count - 1 || !
CanEmitNull))
86 if (_skipDuplicateEndTimes
87 && _lastEnumeratorEndTime.HasValue
88 && enumerator.Current !=
null
89 && enumerator.Current.EndTime <= _lastEnumeratorEndTime)
102 Log.
Debug($
"ConcatEnumerator.MoveNext(): disposing enumerator at position: {_currentIndex} Name: {enumerator.GetType().Name}");
106 enumerator.DisposeSafely();
107 _enumerators[_currentIndex] =
null;
119 throw new InvalidOperationException($
"Can not reset {nameof(ConcatEnumerator)}");
127 foreach (var enumerator
in _enumerators)
129 enumerator.DisposeSafely();