RhSolutions-AddIn/RhSolutions.ExcelExtensions/RowsEnumerator.cs

52 lines
832 B
C#
Raw Normal View History

2023-03-31 15:27:31 +03:00
using System.Collections;
2023-04-01 15:58:42 +03:00
namespace RhSolutions.ExcelExtensions;
2023-03-31 15:27:31 +03:00
2023-04-01 15:58:42 +03:00
public class RowsEnumerator : IEnumerator<Row>
2023-03-31 15:27:31 +03:00
{
2023-04-06 08:29:39 +03:00
private Rows _rows;
private int position = -1;
2023-03-31 15:27:31 +03:00
object IEnumerator.Current
{
get
{
return Current;
}
}
2023-04-01 15:58:42 +03:00
public Row Current
2023-03-31 15:27:31 +03:00
{
get
{
try
{
2023-04-06 08:29:39 +03:00
return _rows[position];
2023-03-31 15:27:31 +03:00
}
catch (IndexOutOfRangeException)
{
throw new InvalidOperationException();
}
}
}
2023-04-06 08:29:39 +03:00
public RowsEnumerator(Rows rows)
2023-03-31 15:27:31 +03:00
{
2023-04-06 08:29:39 +03:00
_rows = rows;
2023-03-31 15:27:31 +03:00
}
public bool MoveNext()
{
position++;
2023-04-06 08:29:39 +03:00
return (position < _rows.Length);
2023-03-31 15:27:31 +03:00
}
public void Reset()
{
2023-04-06 08:29:39 +03:00
position = -1;
2023-03-31 15:27:31 +03:00
}
public void Dispose()
{
}
}