I created this class which lets you create a kind of app.config for dll's
Imports System.Xml
Imports System.Configuration
' usage:
' The xml file must be built like this
'<configuration>
' <assemblySettings>
' <add key="key1" value="Value for key1 (OtherTestLib)"/>
' <add key="key2" value="Value for key2 (OtherTestLib)"/>
' </assemblySettings>
'</configuration>
' Dim settings as AssemblySetting(filename)
' Dim var1 as string = settings("key1")
' Dim var2 as string = settings("key2")
' for enumeration
' Dim settings as IDictionary
' Dim entry as DictionaryEntry
'
' settings = AssemblySetting.GetConfig(filename)
' For Each entry in settings
'
' Next
Public Class AssemblySettings
Private mysettings As IDictionary
Dim entry As DictionaryEntry
Public Sub New(ByVal FileName As String)
mysettings = GetConfig(FileName)
End Sub
Default Public ReadOnly Property KeyValue(ByVal KeyName As String) As String
Get
Dim retVal As Object
If Not mysettings Is Nothing Then
retVal = mysettings(KeyName)
End If
If Not retVal Is Nothing Then
Return CType(retVal, String)
Else
Return ""
End If
End Get
End Property
Shared Function GetConfig(ByVal FileName As String) As IDictionary
Dim doc As XmlDocument = New XmlDocument()
Dim nodes As XmlNodeList
Dim node As XmlNode
doc.Load(FileName)
nodes = doc.GetElementsByTagName("assemblySettings")
For Each node In nodes
If node.LocalName = "assemblySettings" Then Return CType(New
DictionarySectionHandler().Create(Nothing, Nothing, node), IDictionary)
Next
End Function
End Class