RhSolutions-AddIn/RhSolutions.ExcelExtensions/ColumnsEnumerator.cs

52 lines
867 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 ColumnsEnumerator: IEnumerator<Column>
2023-03-31 15:27:31 +03:00
{
2023-04-06 08:29:39 +03:00
private Columns _columns;
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 Column Current
2023-03-31 15:27:31 +03:00
{
get
{
try
{
2023-04-06 08:29:39 +03:00
return _columns[position];
2023-03-31 15:27:31 +03:00
}
catch (IndexOutOfRangeException)
{
throw new InvalidOperationException();
}
}
}
2023-04-06 08:29:39 +03:00
public ColumnsEnumerator(Columns columns)
2023-03-31 15:27:31 +03:00
{
2023-04-06 08:29:39 +03:00
_columns = columns;
2023-03-31 15:27:31 +03:00
}
public bool MoveNext()
{
position++;
2023-04-06 08:29:39 +03:00
return (position < _columns.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()
{
}
}