From a382b37d59b76788e3cd53f977e77ba58f61922f Mon Sep 17 00:00:00 2001 From: Jonathan Jenne Date: Fri, 5 Apr 2019 15:48:52 +0200 Subject: [PATCH] Add constructor to Config Manager which accepts only a userpath for ui settings which will be saved in Roaming --- Config/ConfigManager.vb | 22 ++++++++++++++++++++-- Config/My Project/AssemblyInfo.vb | 4 ++-- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/Config/ConfigManager.vb b/Config/ConfigManager.vb index 0d97ca03..7faa0a6c 100644 --- a/Config/ConfigManager.vb +++ b/Config/ConfigManager.vb @@ -71,6 +71,24 @@ Public Class ConfigManager(Of T) _Config = LoadConfig() End Sub + ''' + ''' Creates a new instance of the ConfigManager. + ''' + ''' + ''' 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) + ''' + ''' LogConfig instance + ''' The path to check for a config file, eg. AppData + Public Sub New(LogConfig As LogConfig, ConfigPath As String) + MyClass.New(LogConfig, ConfigPath, ConfigPath) + End Sub + ''' ''' Save the current config object to `UserConfigPath` ''' @@ -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) diff --git a/Config/My Project/AssemblyInfo.vb b/Config/My Project/AssemblyInfo.vb index e6f4faa3..e988c66c 100644 --- a/Config/My Project/AssemblyInfo.vb +++ b/Config/My Project/AssemblyInfo.vb @@ -12,7 +12,7 @@ Imports System.Runtime.InteropServices - + @@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices ' übernehmen, indem Sie "*" eingeben: ' - +