using System.Collections.Generic; namespace Cobilas.Collections { /// Transforms a collection into an enumerator. public class ICollectionToIEnumerator : ArrayToIEnumerator { /// Gets the element in the collection at the current position of the enumerator. public override T Current => base.Current; #pragma warning disable CS1591 public ICollectionToIEnumerator(ICollection collection) : base() { if (collection is null || collection.Count == 0) return; collection.CopyTo(list = new T[collection.Count], 0); } #pragma warning restore CS1591 /// Advances the enumerator to the next element of the collection. public override bool MoveNext() => base.MoveNext(); /// Sets the enumerator to its initial position, which is before the first element in the collection. public override void Reset() => base.Reset(); /// /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// protected override void Dispose(bool disposing) => base.Dispose(disposing); } }