I did a little Googling and found out that VB.NET gives programmers an object called DictionaryBase. A Dictionary is really just another name for a Hash Table (in VB terms). This made my life a lot easier.
Although I haven't tested yet, I'm pretty positive my Hash and ArrayOfHash classes will work as intended.
I provide them here:
'''''''''
' Hash.vb
' Author:
cparker'
' NOTE: Only provides one-way communication, from server to client.
Imports System
Imports System.Collections
Public Class Hash
Inherits System.Collections.DictionaryBase
Public Sub Populate(ByVal MyHash() As MyProject.MyWebReference.HashEntry)
Dim i As Integer
For i = 0 To MyHash.Length - 1
Add(MyHash(i).key, MyHash(i).value)
Next
End Sub ' Populate
Default Public Property Item(ByVal key As String) As String
Get
Return CType(Dictionary(key), String)
End Get
Set(ByVal value As String)
Dictionary(key) = value
End Set
End Property
Public ReadOnly Property Keys() As ICollection
Get
Return Dictionary.Keys
End Get
End Property
Public ReadOnly Property Values() As ICollection
Get
Return Dictionary.Values
End Get
End Property
Public Sub Add(ByVal key As String, ByVal value As String)
Dictionary.Add(key, value)
End Sub ' Add
Public Function Contains(ByVal key As String) As Boolean
Return Dictionary.Contains(key)
End Function ' Contains
Public Sub Remove(ByVal key As String)
Dictionary.Remove(key)
End Sub ' Remove
End Class ' Hash
''''''''''''''''
''''''''''''''''
' ArrayOfHash.vb
' Author:
cparker'
' NOTE: A simple class. Took a while to play with the logic to make sure the array would be properly filled.
' ----- As of yet, remains untested.
Imports MyProject.Hash
Public Class ArrayOfHash
Dim Self() As Hash
Public Sub Populate(ByVal MyHash()() As MyProject.MyWebReference.HashEntry)
Dim i As Integer
For i = 0 To MyHash.Length - 1
Self(i).Populate(MyHash(i))
Next
End Sub ' Populate
Public Function HashAt(ByVal Location As Integer) As Hash
Return Self(Location)
End Function ' HashAt
End Class ' ArrayOfHash
'''''''''''''''''''''''
These two classes were designed to accommodate the
XML Schema Definition I supplied earlier today (although it seems like yesterday at this point).
I think I'm just about ready to leave. It's been a long day. I'd like to test this code first, though.
lyncollege gets out of work in about an hour. I got paid today. I think I'm going to take her to dinner after work.
(I'm driving her car. Woohoo.) Security Level: Public