diff --git a/Modules.Config/ConfigManager.vb b/Modules.Config/ConfigManager.vb index b62830bc..50a60ddc 100644 --- a/Modules.Config/ConfigManager.vb +++ b/Modules.Config/ConfigManager.vb @@ -11,8 +11,12 @@ Public Class ConfigManager(Of T) Private ReadOnly _LogConfig As LogConfig Private ReadOnly _Logger As Logger Private ReadOnly _File As Filesystem.File + Private ReadOnly _UserDirectory As String + Private ReadOnly _UserConfigPath As String Private ReadOnly _ComputerDirectory As String + Private ReadOnly _ComputerConfigPath As String + Private ReadOnly _TestMode As Boolean = False Private ReadOnly _Blueprint As T @@ -38,12 +42,20 @@ Public Class ConfigManager(Of T) ''' ''' Public ReadOnly Property UserConfigPath As String + Get + Return _UserConfigPath + End Get + End Property ''' ''' Path to the current computer config. Maybe the same as `UserConfigPath` ''' ''' Public ReadOnly Property ComputerConfigPath As String + Get + Return _ComputerConfigPath + End Get + End Property ''' ''' Creates a new instance of the ConfigManager @@ -66,8 +78,8 @@ Public Class ConfigManager(Of T) _ComputerDirectory = _File.CreateDirectory(ComputerConfigPath) _ForceUserConfig = ForceUserConfig - UserConfigPath = Path.Combine(_UserDirectory, USER_CONFIG_NAME) - ComputerConfigPath = Path.Combine(_ComputerDirectory, COMPUTER_CONFIG_NAME) + _UserConfigPath = Path.Combine(_UserDirectory, USER_CONFIG_NAME) + _ComputerConfigPath = Path.Combine(_ComputerDirectory, COMPUTER_CONFIG_NAME) Config = LoadConfig() End Sub @@ -88,7 +100,7 @@ Public Class ConfigManager(Of T) ''' True if save was successful, False otherwise Public Function Save(Optional ForceAll As Boolean = False) As Boolean Try - WriteToFile(Config, UserConfigPath, ForceAll) + WriteToFile(Config, _UserConfigPath, ForceAll) Return True Catch ex As Exception _Logger.Error(ex) @@ -152,9 +164,9 @@ Public Class ConfigManager(Of T) Private Function LoadComputerConfig(ByVal Config As T) As T - If File.Exists(ComputerConfigPath) Then + If File.Exists(_ComputerConfigPath) Then Try - Dim oComputerConfig = ReadFromFile(ComputerConfigPath) + Dim oComputerConfig = ReadFromFile(_ComputerConfigPath) CopyValues(oComputerConfig, Config) Catch ex As Exception _Logger.Error(ex) @@ -169,9 +181,9 @@ Public Class ConfigManager(Of T) End Function Private Function LoadUserConfig(ByVal Config As T) As T - If File.Exists(UserConfigPath) Then + If File.Exists(_UserConfigPath) Then Try - Dim oUserConfig = ReadFromFile(UserConfigPath) + Dim oUserConfig = ReadFromFile(_UserConfigPath) ' if user config exists If Not IsNothing(oUserConfig) Then