aboutsummaryrefslogtreecommitdiff
path: root/RhSolutions.ExcelExtensions/ColumnsEnumerator.cs
blob: 40ad4d6f80a91316bb9a3956a1f0ee285b0208ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using System.Collections;

namespace RhSolutions.ExcelExtensions;

public class ColumnsEnumerator: IEnumerator<Column>
{
    private Columns _columns;
    private int position = -1;
    object IEnumerator.Current
    {
        get
        {
            return Current;
        }
    }

    public Column Current
    {
        get
        {
            try
            {
                return _columns[position];
            }
            catch (IndexOutOfRangeException)
            {
                throw new InvalidOperationException();
            }
        }
    }

    public ColumnsEnumerator(Columns columns)
    {
        _columns = columns;
    }

    public bool MoveNext()
    {
        position++;
        return (position < _columns.Length);
    }

    public void Reset()
    {
        position = -1;
    }

    public void Dispose()
    {

    }
}