ConfigManager: fix paths
This commit is contained in:
parent
5e488b6526
commit
cd5f982b46
@ -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)
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public ReadOnly Property UserConfigPath As String
|
||||
Get
|
||||
Return _UserConfigPath
|
||||
End Get
|
||||
End Property
|
||||
|
||||
''' <summary>
|
||||
''' Path to the current computer config. Maybe the same as `UserConfigPath`
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public ReadOnly Property ComputerConfigPath As String
|
||||
Get
|
||||
Return _ComputerConfigPath
|
||||
End Get
|
||||
End Property
|
||||
|
||||
''' <summary>
|
||||
''' 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)
|
||||
''' <returns>True if save was successful, False otherwise</returns>
|
||||
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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user