using System; using System.Collections; using System.Collections.Generic; namespace AMWD.Common.Cli { /// /// Walks through an and allows retrieving additional items. /// /// /// /// Initialises a new instance of the class. /// /// The array to walk though. internal class EnumerableWalker(IEnumerable array) : IEnumerable where T : class { private readonly IEnumerable _array = array ?? throw new ArgumentNullException(nameof(array)); private IEnumerator _enumerator; IEnumerator IEnumerable.GetEnumerator() { _enumerator = _array.GetEnumerator(); return _enumerator; } /// /// Gets the enumerator. /// /// The enumerator. public IEnumerator GetEnumerator() { _enumerator = _array.GetEnumerator(); return _enumerator; } /// /// Gets the next item. /// /// The next item. public T GetNext() { if (_enumerator.MoveNext()) { return _enumerator.Current; } else { return default; } } } }