Add constructor to Config Manager which accepts only a userpath for ui settings which will be saved in Roaming
This commit is contained in:
parent
9010ad4139
commit
a382b37d59
@ -71,6 +71,24 @@ Public Class ConfigManager(Of T)
|
|||||||
_Config = LoadConfig()
|
_Config = LoadConfig()
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
''' <summary>
|
||||||
|
''' Creates a new instance of the ConfigManager.
|
||||||
|
''' </summary>
|
||||||
|
''' <example>
|
||||||
|
''' Public Class Config
|
||||||
|
''' Public Property StringEntry As String = "TEST"
|
||||||
|
''' Public Property BoolEntry As Boolean = True
|
||||||
|
''' Public Property IntEntry As Integer = 123
|
||||||
|
''' End Class
|
||||||
|
'''
|
||||||
|
''' Dim oConfigManager = New ConfigManager(Of Config)(_LogConfig, Application.UserAppDataPath)
|
||||||
|
''' </example>
|
||||||
|
''' <param name="LogConfig">LogConfig instance</param>
|
||||||
|
''' <param name="ConfigPath">The path to check for a config file, eg. AppData</param>
|
||||||
|
Public Sub New(LogConfig As LogConfig, ConfigPath As String)
|
||||||
|
MyClass.New(LogConfig, ConfigPath, ConfigPath)
|
||||||
|
End Sub
|
||||||
|
|
||||||
''' <summary>
|
''' <summary>
|
||||||
''' Save the current config object to `UserConfigPath`
|
''' Save the current config object to `UserConfigPath`
|
||||||
''' </summary>
|
''' </summary>
|
||||||
@ -87,11 +105,11 @@ Public Class ConfigManager(Of T)
|
|||||||
Private Function LoadConfig() As T
|
Private Function LoadConfig() As T
|
||||||
Dim oConfig As T
|
Dim oConfig As T
|
||||||
|
|
||||||
If IO.File.Exists(_UserPath) Then
|
If File.Exists(_UserPath) Then
|
||||||
_Logger.Debug("Loading config from UserPath: {0}", _UserPath)
|
_Logger.Debug("Loading config from UserPath: {0}", _UserPath)
|
||||||
_CurrentDataPath = _UserPath
|
_CurrentDataPath = _UserPath
|
||||||
oConfig = ReadFromFile(_UserPath)
|
oConfig = ReadFromFile(_UserPath)
|
||||||
ElseIf IO.File.Exists(_ComputerPath) Then
|
ElseIf File.Exists(_ComputerPath) Then
|
||||||
_Logger.Debug("Loading config from ComputerPath: {0}", _ComputerPath)
|
_Logger.Debug("Loading config from ComputerPath: {0}", _ComputerPath)
|
||||||
_CurrentDataPath = _ComputerPath
|
_CurrentDataPath = _ComputerPath
|
||||||
oConfig = ReadFromFile(_ComputerPath)
|
oConfig = ReadFromFile(_ComputerPath)
|
||||||
|
|||||||
@ -12,7 +12,7 @@ Imports System.Runtime.InteropServices
|
|||||||
<Assembly: AssemblyDescription("")>
|
<Assembly: AssemblyDescription("")>
|
||||||
<Assembly: AssemblyCompany("")>
|
<Assembly: AssemblyCompany("")>
|
||||||
<Assembly: AssemblyProduct("Modules.Config")>
|
<Assembly: AssemblyProduct("Modules.Config")>
|
||||||
<Assembly: AssemblyCopyright("Copyright © 2018")>
|
<Assembly: AssemblyCopyright("Copyright © 2019")>
|
||||||
<Assembly: AssemblyTrademark("")>
|
<Assembly: AssemblyTrademark("")>
|
||||||
|
|
||||||
<Assembly: ComVisible(False)>
|
<Assembly: ComVisible(False)>
|
||||||
@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
|
|||||||
' übernehmen, indem Sie "*" eingeben:
|
' übernehmen, indem Sie "*" eingeben:
|
||||||
' <Assembly: AssemblyVersion("1.0.*")>
|
' <Assembly: AssemblyVersion("1.0.*")>
|
||||||
|
|
||||||
<Assembly: AssemblyVersion("1.0.0.0")>
|
<Assembly: AssemblyVersion("1.0.0.1")>
|
||||||
<Assembly: AssemblyFileVersion("1.0.0.0")>
|
<Assembly: AssemblyFileVersion("1.0.0.0")>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user