Add constructor to Config Manager which accepts only a userpath for ui settings which will be saved in Roaming

This commit is contained in:
Jonathan Jenne 2019-04-05 15:48:52 +02:00
parent 9010ad4139
commit a382b37d59
2 changed files with 22 additions and 4 deletions

View File

@ -71,6 +71,24 @@ Public Class ConfigManager(Of T)
_Config = LoadConfig()
End Sub
''' <summary>
''' Creates a new instance of the ConfigManager.
''' </summary>
''' <example>
''' Public Class Config
''' Public Property StringEntry As String = "TEST"
''' Public Property BoolEntry As Boolean = True
''' Public Property IntEntry As Integer = 123
''' End Class
'''
''' Dim oConfigManager = New ConfigManager(Of Config)(_LogConfig, Application.UserAppDataPath)
''' </example>
''' <param name="LogConfig">LogConfig instance</param>
''' <param name="ConfigPath">The path to check for a config file, eg. AppData</param>
Public Sub New(LogConfig As LogConfig, ConfigPath As String)
MyClass.New(LogConfig, ConfigPath, ConfigPath)
End Sub
''' <summary>
''' Save the current config object to `UserConfigPath`
''' </summary>
@ -87,11 +105,11 @@ Public Class ConfigManager(Of T)
Private Function LoadConfig() As T
Dim oConfig As T
If IO.File.Exists(_UserPath) Then
If File.Exists(_UserPath) Then
_Logger.Debug("Loading config from UserPath: {0}", _UserPath)
_CurrentDataPath = _UserPath
oConfig = ReadFromFile(_UserPath)
ElseIf IO.File.Exists(_ComputerPath) Then
ElseIf File.Exists(_ComputerPath) Then
_Logger.Debug("Loading config from ComputerPath: {0}", _ComputerPath)
_CurrentDataPath = _ComputerPath
oConfig = ReadFromFile(_ComputerPath)

View File

@ -12,7 +12,7 @@ Imports System.Runtime.InteropServices
<Assembly: AssemblyDescription("")>
<Assembly: AssemblyCompany("")>
<Assembly: AssemblyProduct("Modules.Config")>
<Assembly: AssemblyCopyright("Copyright © 2018")>
<Assembly: AssemblyCopyright("Copyright © 2019")>
<Assembly: AssemblyTrademark("")>
<Assembly: ComVisible(False)>
@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
' übernehmen, indem Sie "*" eingeben:
' <Assembly: AssemblyVersion("1.0.*")>
<Assembly: AssemblyVersion("1.0.0.0")>
<Assembly: AssemblyVersion("1.0.0.1")>
<Assembly: AssemblyFileVersion("1.0.0.0")>