mercredi 4 février 2015

VB.net staggerred array of different types


Vote count:

0




I'm creating a Windows application in VB.NET in which needs to store a decent amount of associative information about different applications. I'm trying to find out what the best way to store this data.


After doing some research the best solution that I have found is to use arrays of objects, or dictionaries of objects.


Here is my data structure that needs to be stored:



var Info[AppID]['AppName']-> String (returns the app name as String)
['Exes'] -> Array of Strings
['RegKeys'] -> Array of Strings
['Versions'][VersionID]['PCID'] -> String
['Date'] -> DateTime
['Size'] -> Integer


The keys without quotes are dynamic and represent the actual AppID/VersionID, the keys in quotes are static (so the 2nd key will always have 'AppName' 'Exes' etc.


So for example:



Info[123ab]['Name'] = 'Internet Exploder'
['Exes'] = {'iexplore.exe', 'whatever.exe'}
['RegKeys'] = {'hkey/local machine .....'}
['Versions'][1]['PCID'] = 'My Desktop'
['Date'] = Jan 1 1960
['Size'] = 9001


would be declared and set up as



Dim appinfo As New Dictionary(Of String, Object)
Dim Lv2 As New Dictionary(Of String, Object)

Dim Exes As New List(Of String)(New String() {"iexplorer.exe", "whatever.exe"})
Dim RegKeys As New List(Of String)(New String() {"blah"})
Dim Directories As New List(Of String)(New String() {"c:\program files\internet explorer"})
Dim Name As String = "Internet Exploder"
Dim Versions As New Dictionary(Of String, Object)
Dim VersionsLv2 As New Dictionary(Of String, Object)

Dim VersionID As String = "1"
Dim PCID As String = "My Desktop"
Dim TheDate As Date = Now
Dim Size As Integer = 9001

VersionsLv2.Add("PCID", PCID)
VersionsLv2.Add("Date", TheDate)
VersionsLv2.Add("Size", Size)

Versions.Add("VersionID", VersionsLv2)

Lv2.Add("Name", Name)
Lv2.Add("RegKeys", RegKeys)
Lv2.Add("Directories", Directories)
Lv2.Add("Versions", Versions)

appinfo.Add("abc12", Lv2)


I'm just wondering if anyone knows any better way to do this? I kind of hate having to work from the top of the tree down in order to initialize the variable, but this seems to work ok.


Thank you very much for your input!



asked 49 secs ago







VB.net staggerred array of different types

Aucun commentaire:

Enregistrer un commentaire