using System.Collections; using System.Collections.Generic; using System.Linq; namespace InABox.Core { public class CoreTableAdapter : IEnumerable where T : BaseObject, new() { private List? _objects; private readonly CoreTable _table; public CoreTableAdapter(CoreTable table) { _table = table; } private List Objects { get => _objects ??= _table.Rows.Select(row => row.ToObject()).ToList(); } public T this[int index] => Objects[index]; public IEnumerator GetEnumerator() { return GetObjects(); } IEnumerator IEnumerable.GetEnumerator() { return GetObjects(); } private IEnumerator GetObjects() { return Objects.GetEnumerator(); } } }