Imports System.Configuration
Imports System

Public Class AppConfig

    Public Shared Function GetConfiguration() As ConfigValues

        Dim appfile As String = My.Application.Info.DirectoryPath & "\" & My.Application.Info.ProductName & ".exe"
        Dim appconfig As Configuration = ConfigurationManager.OpenExeConfiguration(appfile)
        Dim appsettings As AppSettingsSection = appconfig.AppSettings
        Dim settings As KeyValueConfigurationCollection = appsettings.Settings

        Dim values As New ConfigValues()

        values.username = settings.Item("dpma_username").Value
        values.password = settings.Item("dpma_password").Value
        values.query = settings.Item("dpma_query").Value
        values.queryIgnore = settings.Item("dpma_query_ignore").Value
        values.connstring = settings.Item("sql_connstring").Value
        values.database = settings.Item("sql_database").Value
        values.searchType = settings.Item("search_type").Value

        Return values
    End Function

    Public Shared Function GetVersion()
        Dim assembly As System.Reflection.Assembly = System.Reflection.Assembly.GetExecutingAssembly()
        Dim fvi As FileVersionInfo = FileVersionInfo.GetVersionInfo(assembly.Location)
        Dim version As String = fvi.FileVersion
        Return version
    End Function

End Class

Public Class ConfigValues
    Public username As String
    Public password As String
    Public query As String
    Public queryIgnore As String
    Public connstring As String
    Public database As String
    Public searchType As String

    Public Sub New()
    End Sub
End Class