From 4730a3f19cd9f04a33d6fa03cf95bc67cb6f531c Mon Sep 17 00:00:00 2001 From: Jonathan Jenne Date: Thu, 13 Feb 2020 12:06:57 +0100 Subject: [PATCH] Change ctor signatures to keep backwards compat with all products, simplify config loading --- Modules.Config/ConfigManager.vb | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/Modules.Config/ConfigManager.vb b/Modules.Config/ConfigManager.vb index 446190e2..41f5350b 100644 --- a/Modules.Config/ConfigManager.vb +++ b/Modules.Config/ConfigManager.vb @@ -74,7 +74,7 @@ Public Class ConfigManager(Of T) ''' The path to check for a computer config file, eg. ProgramData (Usually Application.CommonAppDataPath) ''' The path to check for a third config file. This is useful when running the Application in an environment where AppData/ProgramData directories are not available ''' Override values from ComputerConfig with UserConfig - Public Sub New(LogConfig As LogConfig, UserConfigPath As String, ComputerConfigPath As String, ApplicationStartupPath As String, Optional ForceUserConfig As Boolean = False) + Public Sub New(LogConfig As LogConfig, UserConfigPath As String, ComputerConfigPath As String, Optional ApplicationStartupPath As String = "", Optional ForceUserConfig As Boolean = False) _LogConfig = LogConfig _Logger = LogConfig.GetLogger() _File = New Filesystem.File(_LogConfig) @@ -100,8 +100,8 @@ Public Class ConfigManager(Of T) ''' ''' LogConfig instance ''' The path to check for a user config file, eg. AppData (Usually Application.UserAppDataPath or Application.LocalUserAppDataPath) - Public Sub New(LogConfig As LogConfig, ConfigPath As String, ApplicationStartupPath As String) - MyClass.New(LogConfig, ConfigPath, ConfigPath, ApplicationStartupPath, ForceUserConfig:=True) + Public Sub New(LogConfig As LogConfig, ConfigPath As String) + MyClass.New(LogConfig, ConfigPath, String.Empty, String.Empty, ForceUserConfig:=True) End Sub ''' @@ -168,14 +168,10 @@ Public Class ConfigManager(Of T) Dim oConfig = Activator.CreateInstance(_BlueprintType) ' try to load the special app config - ' returns nothing if app was not found or could not be loaded oConfig = LoadAppConfig(oConfig) - If oConfig Is Nothing Then - oConfig = Activator.CreateInstance(_BlueprintType) - ' then Try to load computer config - oConfig = LoadComputerConfig(oConfig) - End If + ' try to load the computer config + oConfig = LoadComputerConfig(oConfig) ' now try to load userconfig oConfig = LoadUserConfig(oConfig) @@ -190,12 +186,10 @@ Public Class ConfigManager(Of T) Catch ex As Exception _Logger.Error(ex) _Logger.Warn("ApplicationConfig could not be loaded!") - Return Nothing End Try Else _Logger.Debug("ApplicationConfig does not exist.") _ForceUserConfig = True - Return Nothing End If Return Config