19 using System.Collections;
20 using System.Collections.Generic;
32 private IEnumerator<T> _enumerator;
33 private readonly Func<IEnumerator<T>> _enumeratorFactory;
42 _enumeratorFactory = enumeratorFactory;
54 if (_enumerator ==
null)
56 _enumerator = _enumeratorFactory.Invoke();
62 moveNext = _enumerator.MoveNext();
65 _current = _enumerator.Current;
68 catch (IOException exception)
71 if (exception.Message ==
null || !exception.Message.Contains(
"Stale file handle", StringComparison.InvariantCultureIgnoreCase))
79 _enumerator.DisposeSafely();
82 _current =
default(T);
94 if (_enumerator !=
null)
108 get {
return _current; }
118 object IEnumerator.Current
129 if (_enumerator !=
null)
131 _enumerator.Dispose();