using System.Collections; using System.Collections.Concurrent; using Connected.Interop; namespace Connected.Caching; internal class EntryEnumerator : IEnumerator { public EntryEnumerator(ConcurrentDictionary items) { Items = items; Index = -1; } private int Count => Items.Count; private int Index { get; set; } private ConcurrentDictionary Items { get; } public T Current => TypeConversion.TryConvert(Items.ElementAt(Index).Value.Instance, out T result) ? result : default; object IEnumerator.Current => Current; public void Dispose() { } public bool MoveNext() { if (Index < Count - 1) { Index++; return true; } return false; } public void Reset() { Index = -1; } }