Change ctor signatures to keep backwards compat with all products, simplify config loading
This commit is contained in:
parent
efd2d79df6
commit
4730a3f19c
@ -74,7 +74,7 @@ Public Class ConfigManager(Of T)
|
||||
''' <param name="ComputerConfigPath">The path to check for a computer config file, eg. ProgramData (Usually Application.CommonAppDataPath)</param>
|
||||
''' <param name="ApplicationStartupPath">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</param>
|
||||
''' <param name="ForceUserConfig">Override values from ComputerConfig with UserConfig</param>
|
||||
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)
|
||||
''' </summary>
|
||||
''' <param name="LogConfig">LogConfig instance</param>
|
||||
''' <param name="ConfigPath">The path to check for a user config file, eg. AppData (Usually Application.UserAppDataPath or Application.LocalUserAppDataPath)</param>
|
||||
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
|
||||
|
||||
''' <summary>
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user