I have CurrentIndex, and IndexOf(row) enhancements for Doodads Business Entity in Both VB and C# Code is as Follows VB first then C#:
''' <summary>
''' Gets or sets the index of the current row.
''' </summary>
''' <value>The index of the current.</value>
Public Property CurrentIndex() As Integer
Get
Return _currentIndex
End Get
Set(ByVal value As Integer)
_currentIndex = value
End Set
End Property
''' <summary>
''' Rewinds this instance.
''' </summary>
Public Sub Rewind()
_dataRow = Nothing
_enumerator = Nothing
_currentIndex = 0
If Not _dataTable Is Nothing Then
If (_dataTable.DefaultView.Count > 0) Then
_enumerator = _dataTable.DefaultView.GetEnumerator()
_enumerator.MoveNext()
Dim rowView As DataRowView = CType(_enumerator.Current, DataRowView)
_dataRow = rowView.Row
_currentIndex = 0
_EOF = False
Else
_EOF = True
End If
Else
_EOF = True
End If
End Sub
''' <summary>
''' Moves the next.
''' </summary>
''' <returns></returns>
Public Function MoveNext() As Boolean
Dim moved As Boolean = False
If Not _enumerator Is Nothing AndAlso _enumerator.MoveNext() Then
Dim rowView As DataRowView = CType(_enumerator.Current, DataRowView)
_dataRow = rowView.Row
moved = True
_currentIndex += 1
Else
_EOF = True
End If
Return moved
End Function
''' <summary>
''' Returns the Index of the Row.
''' </summary>
''' <param name="Row">The row.</param>
''' <returns></returns>
Public Function IndexOf(ByVal Row As DataRow) As Integer
If Not _dataTable Is Nothing Then
Return _dataTable.Rows.IndexOf(Row)
Else
Return -1
End If
End Function
============================================================================================================
''' <summary>
''' Gets or sets the index of the current row.
''' </summary>
''' <value>The index of the current.</value>
Public Property CurrentIndex() As Integer
Get
Return _currentIndex
End Get
Set(ByVal value As Integer)
_currentIndex = value
End Set
End Property
''' <summary>
''' Rewinds this instance.
''' </summary>
Public Sub Rewind()
_dataRow = Nothing
_enumerator = Nothing
_currentIndex = 0
If Not _dataTable Is Nothing Then
If (_dataTable.DefaultView.Count > 0) Then
_enumerator = _dataTable.DefaultView.GetEnumerator()
_enumerator.MoveNext()
Dim rowView As DataRowView = CType(_enumerator.Current, DataRowView)
_dataRow = rowView.Row
_currentIndex = 0
_EOF = False
Else
_EOF = True
End If
Else
_EOF = True
End If
End Sub
''' <summary>
''' Moves the next.
''' </summary>
''' <returns></returns>
Public Function MoveNext() As Boolean
Dim moved As Boolean = False
If Not _enumerator Is Nothing AndAlso _enumerator.MoveNext() Then
Dim rowView As DataRowView = CType(_enumerator.Current, DataRowView)
_dataRow = rowView.Row
moved = True
_currentIndex += 1
Else
_EOF = True
End If
Return moved
End Function
''' <summary>
''' Returns the Index of the Row.
''' </summary>
''' <param name="Row">The row.</param>
''' <returns></returns>
Public Function IndexOf(ByVal Row As DataRow) As Integer
If Not _dataTable Is Nothing Then
Return _dataTable.Rows.IndexOf(Row)
Else
Return -1
End If
End Function
=====================================================================================================================================
/// <summary>
/// Gets or sets the index of the current row.
/// </summary>
/// <value>The index of the current.</value>
public int CurrentIndex {
get { return _currentIndex; }
set { _currentIndex = value; }
}
/// <summary>
/// Rewinds this instance.
/// </summary>
public void Rewind()
{
_dataRow = null;
_enumerator = null;
_currentIndex = 0;
if ((_dataTable != null)) {
if ((_dataTable.DefaultView.Count > 0)) {
_enumerator = _dataTable.DefaultView.GetEnumerator();
_enumerator.MoveNext();
DataRowView rowView = (DataRowView)_enumerator.Current;
_dataRow = rowView.Row;
_currentIndex = 0;
_EOF = false;
}
else {
_EOF = true;
}
}
else {
_EOF = true;
}
}
/// <summary>
/// Moves the next.
/// </summary>
/// <returns></returns>
public bool MoveNext()
{
bool moved = false;
if ((_enumerator != null) && _enumerator.MoveNext()) {
DataRowView rowView = (DataRowView)_enumerator.Current;
_dataRow = rowView.Row;
moved = true;
_currentIndex += 1;
}
else {
_EOF = true;
}
return moved;
}
/// <summary>
/// Returns the Index of the Row.
/// </summary>
/// <param name="Row">The row.</param>
/// <returns></returns>
public int IndexOf(DataRow Row)
{
if ((_dataTable != null)) {
return _dataTable.Rows.IndexOf(Row);
}
else {
return -1;
}
}
Code for Business Entity Enhancements in VB and C-sharp