More Logging for Config Module, Add ControlPatcher, Add More UIConfig Items

This commit is contained in:
Jonathan Jenne
2019-02-22 15:13:26 +01:00
parent c6537536f5
commit bad7cea8d6
16 changed files with 276 additions and 94 deletions

View File

@@ -1,8 +1,6 @@
Imports System.IO
Imports System.Xml.Serialization
Imports DigitalData.Modules.Logging
Imports DigitalData.Modules.Filesystem
Imports System.Xml
Public Class ConfigManager(Of T)
Private Const USER_CONFIG_NAME As String = "UserConfig.xml"
@@ -51,22 +49,22 @@ Public Class ConfigManager(Of T)
_Serializer = New XmlSerializer(_Blueprint.GetType)
If Not Directory.Exists(UserConfigPath) Then
_Logger.Debug("UserConfigPath {0} did not exist and was created", UserConfigPath)
Directory.CreateDirectory(UserConfigPath)
'Throw New DirectoryNotFoundException($"Path {UserConfigPath} does not exist!")
End If
If Not _File.TestPathIsDirectory(UserConfigPath) Then
_Logger.Warn("UserConfigPath {0} is not a directory", UserConfigPath)
Throw New ArgumentException($"Path {UserConfigPath} is not a directory!")
End If
If Not Directory.Exists(ComputerConfigPath) Then
_Logger.Debug("ComputerConfigPath {0} did not exist and was created", ComputerConfigPath)
Directory.CreateDirectory(ComputerConfigPath)
'Throw New DirectoryNotFoundException($"Path {ComputerConfigPath} does not exist!")
End If
If Not _File.TestPathIsDirectory(ComputerConfigPath) Then
_Logger.Warn("ComputerConfigPath {0} is not a directory", ComputerConfigPath)
Throw New ArgumentException($"Path {ComputerConfigPath} is not a directory!")
End If
@@ -160,7 +158,10 @@ Public Class ConfigManager(Of T)
oConfig = _Serializer.Deserialize(oReader)
End Using
' If oConfig is Nothing, a config file was created but nothing was written to it.
' In this case we need to create oConfig from defaults so we have at least some config object
If oConfig Is Nothing Then
_Logger.Debug("Config file is valid but empty. Loading default values")
oConfig = Activator.CreateInstance(_Blueprint.GetType)
End If