fix ConfigUtils
This commit is contained in:
parent
441f65915f
commit
b3b3e80509
@ -6,9 +6,9 @@ Imports DigitalData.Modules.Config.ConfigAttributes
|
||||
Imports DigitalData.Modules.Base
|
||||
|
||||
Public Class ConfigManager(Of T)
|
||||
Private Const USER_CONFIG_NAME As String = "UserConfig.xml"
|
||||
Private Const COMPUTER_CONFIG_NAME As String = "ComputerConfig.xml"
|
||||
Private Const APP_CONFIG_NAME As String = "AppConfig.xml"
|
||||
Public Const USER_CONFIG_NAME As String = "UserConfig.xml"
|
||||
Public Const COMPUTER_CONFIG_NAME As String = "ComputerConfig.xml"
|
||||
Public Const APP_CONFIG_NAME As String = "AppConfig.xml"
|
||||
|
||||
Private ReadOnly _LogConfig As LogConfig
|
||||
Private ReadOnly _Logger As Logger
|
||||
|
||||
@ -7,22 +7,12 @@ Public Class ConfigUtils
|
||||
Private _File As FilesystemEx
|
||||
|
||||
Private Const MIGRATE_DIRECTORY As String = "Migrate"
|
||||
Private Const USER_CONFIG As String = "UserConfig.xml"
|
||||
|
||||
|
||||
Public Sub New(LogConfig As LogConfig)
|
||||
_Logger = LogConfig.GetLogger()
|
||||
_File = New FilesystemEx(LogConfig)
|
||||
End Sub
|
||||
|
||||
Public Function TestMigrationNeeded(TargetDirectory As String) As Boolean
|
||||
If IO.Directory.Exists(TargetDirectory) Then
|
||||
Return False
|
||||
Else
|
||||
Return True
|
||||
End If
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' Migrate a config file when the ProductName has changed
|
||||
''' </summary>
|
||||
@ -30,11 +20,11 @@ Public Class ConfigUtils
|
||||
''' <param name="pProductName">The current or new product name</param>
|
||||
''' <param name="pOldProductName">The old product name</param>
|
||||
''' <returns></returns>
|
||||
Public Function MigrateAppDataConfig(pBasePath As String, pProductName As String, pOldProductName As String)
|
||||
Private Function MigrateAppDataConfig(pBasePath As String, pConfigName As String, pProductName As String, pOldProductName As String)
|
||||
Dim oNewDirPath = pBasePath
|
||||
Dim oOldDirPath = oNewDirPath.Replace(pProductName, pOldProductName)
|
||||
Dim oNewFilePath = Path.Combine(oNewDirPath, USER_CONFIG)
|
||||
Dim oOldFilePath = Path.Combine(oOldDirPath, USER_CONFIG)
|
||||
Dim oNewFilePath = Path.Combine(oNewDirPath, pConfigName)
|
||||
Dim oOldFilePath = Path.Combine(oOldDirPath, pConfigName)
|
||||
|
||||
' If there is already a new config, exit.
|
||||
If File.Exists(oNewFilePath) Then
|
||||
@ -63,6 +53,14 @@ Public Class ConfigUtils
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function TestMigrationNeeded(TargetDirectory As String) As Boolean
|
||||
If IO.Directory.Exists(TargetDirectory) Then
|
||||
Return False
|
||||
Else
|
||||
Return True
|
||||
End If
|
||||
End Function
|
||||
|
||||
Public Sub MigrateConfig(SourceDirectory As String, TargetDirectory As String, Optional FilePattern As String = "*.*")
|
||||
'If IO.Directory.Exists(TargetDirectory) Then
|
||||
' _Logger.Warn("Config Migration aborted because new config directory [{0}] already exists!", TargetDirectory)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user