|
' ___________________________________________________
'
' � Hi-Integrity Systems 2007. All rights reserved.
' www.hisystems.com.au - Toby Wicks
' ___________________________________________________
'
Option Strict On
Option Explicit On
Namespace SQL
Public Class SQLFieldValues
Implements IEnumerable
Private pobjFields As ArrayList = New ArrayList
Public Sub New()
MyBase.New()
End Sub
Public Function Add() As SQLFieldValue
Return Add("", Nothing)
End Function
Public Function Add(ByVal objFieldAndValue As SQLFieldValue) As SQLFieldValue
Return Add(objFieldAndValue.Name, objFieldAndValue.Value)
End Function
Public Function Add( _
ByVal strName As String, _
ByVal objEqualToValue As Object) As SQLFieldValue
Dim objSQLFieldValue As New SQLFieldValue(strName, objEqualToValue)
pobjFields.Add(objSQLFieldValue)
Return objSQLFieldValue
End Function
Public Sub Add(ByVal objFieldValues As SQLFieldValues)
For Each objFieldValue As SQLFieldValue In objFieldValues
Me.Add(objFieldValue)
Next
End Sub
Default Public ReadOnly Property Item(ByVal strFieldName As String) As SQLFieldValue
Get
Return DirectCast(pobjFields.Item(FieldNameIndex(strFieldName)), SQLFieldValue)
End Get
End Property
Default Public ReadOnly Property Item(ByVal intIndex As Integer) As SQLFieldValue
Get
Return DirectCast(pobjFields.Item(intIndex), SQLFieldValue)
End Get
End Property
Public ReadOnly Property Count() As Integer
Get
Return pobjFields.Count()
End Get
End Property
Public Function Exists(ByVal strFieldName As String) As Boolean
Return FieldNameIndex(strFieldName) >= 0
End Function
Public Sub Delete(ByRef objFieldValue As SQLFieldValue)
If Not pobjFields.Contains(objFieldValue) Then
Throw New ObjectDoesNotExistException
End If
pobjFields.Remove(objFieldValue)
objFieldValue = Nothing
End Sub
Friend Function FieldNameIndex(ByVal strFieldName As String) As Integer
Dim objSQLFieldValue As SQLFieldValue
strFieldName = strFieldName.Trim()
For intIndex As Integer = 0 To Me.Count - 1
objSQLFieldValue = DirectCast(pobjFields.Item(intIndex), SQLFieldValue)
If String.Compare(strFieldName, objSQLFieldValue.Name, ignoreCase:=True) = 0 Then
Return intIndex
End If
Next
Return -1
End Function
Private Function GetEnumerator() As System.Collections.IEnumerator Implements System.Collections.IEnumerable.GetEnumerator
Return pobjFields.GetEnumerator
End Function
End Class
End Namespace
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.