DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
SimpleRowEnumerator.cs
Go to the documentation of this file.
1 //
2 // Copyright 2010-2015 Deveel
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16 
17 using System;
18 using System.Collections;
19 using System.Collections.Generic;
20 
21 namespace Deveel.Data.Sql.Tables {
22  public class SimpleRowEnumerator : IEnumerator<Row> {
23  private readonly ITable source;
24  private int index = -1;
25  private int rowCount;
26 
27  public SimpleRowEnumerator(ITable source) {
28  if (source == null)
29  throw new ArgumentNullException("source");
30 
31  this.source = source;
32  rowCount = source.RowCount;
33  }
34 
35  public void Dispose() {
36  }
37 
38  public bool MoveNext() {
39  return ++index < rowCount;
40  }
41 
42  public void Reset() {
43  rowCount = source.RowCount;
44  index = -1;
45  }
46 
47  public Row Current {
48  get { return new Row(source, new RowId(source.TableInfo.Id, index)); }
49  }
50 
51  object IEnumerator.Current {
52  get { return Current; }
53  }
54  }
55 }
Defines the contract to access the data contained into a table of a database.
Definition: ITable.cs:40
A single row in a table of a database.
Definition: Row.cs:44
int RowCount
Gets the total number of rows in the table.
Definition: ITable.cs:52
Defines the value of a ROWID object, that is a unique reference within a database system to a single ...
Definition: RowId.cs:24