Namespace Client
Public Class DescriptorInfo
Private _id As Integer ' the unique ID of the descriptor
Private _typeID As Integer ' the internal descriptor type
Private _term As Term ' descriptor term in a given language
Friend Sub New(ByVal ID As Integer, ByVal typeID As Integer, ByVal term As Term)
MyBase.New()
If term Is Nothing Then
Throw New ArgumentNullException("term")
End If
_id = ID
_typeID = typeID
_term = term
End Sub
Friend Sub New(ByVal row As DataRow)
Debug.Assert(Not row Is Nothing)
' Note: See the Term constructor to learn what fields it expects...
Me.New(CInt(row("DescriptorID")), CInt(row("TypeID")), New Term(row))
End Sub
Public ReadOnly Property ID() As Integer
Get
Return _id
End Get
End Property
Public ReadOnly Property TypeID() As Integer
Get
Return _typeID
End Get
End Property
Public ReadOnly Property Term() As Term
Get
Return _term
End Get
End Property
End Class
Public Class DescriptorInfoCollection
Implements IEnumerable
Private _table As DataTable
Friend Sub New(ByVal table As DataTable)
MyBase.New()
_table = table
End Sub
Public ReadOnly Property Count() As Integer
Get
Return _table.Rows.Count
End Get
End Property
Default Public ReadOnly Property Item(ByVal index As Integer) As DescriptorInfo
Get
Return New DescriptorInfo(_table.Rows(index)) ' here is the Friend DescriptorInfo.ctor
End Get
End Property
Private Function GetEnumerator() As System.Collections.IEnumerator Implements System.Collections.IEnumerable.GetEnumerator
Return New Enumerator(_table)
End Function
Private Class Enumerator
Implements IEnumerator
Private _tableEnumerator As IEnumerator
Public Sub New(ByVal table As DataTable)
_tableEnumerator = table.Rows.GetEnumerator()
End Sub
Public ReadOnly Property Current() As Object Implements System.Collections.IEnumerator.Current
Get
If Not _tableEnumerator.Current Is Nothing Then
Return New DescriptorInfo(DirectCast(_tableEnumerator.Current, DataRow)) ' here is the Friend constructor again
End If
End Get
End Property
Public Function MoveNext() As Boolean Implements System.Collections.IEnumerator.MoveNext
Return _tableEnumerator.MoveNext()
End Function
Public Sub Reset() Implements System.Collections.IEnumerator.Reset
_tableEnumerator.Reset()
End Sub
End Class
End Class
End Namespace