diff --git a/Config/ConfigManager.vb b/Config/ConfigManager.vb
index c93a3a88..5abbe674 100644
--- a/Config/ConfigManager.vb
+++ b/Config/ConfigManager.vb
@@ -2,13 +2,19 @@
Imports System.Reflection
Imports System.Xml.Serialization
Imports DigitalData.Modules.Config
+Imports DigitalData.Modules.Base
+Imports ConnectionStringAttribute = DigitalData.Modules.Config.ConfigAttributes.ConnectionStringAttribute
+Imports ConnectionStringAppServerAttribute = DigitalData.Modules.Config.ConfigAttributes.ConnectionStringAppServerAttribute
+Imports ConnectionStringTestAttribute = DigitalData.Modules.Config.ConfigAttributes.ConnectionStringTestAttribute
+Imports EDMIAppServerAttribute = DigitalData.Modules.Config.ConfigAttributes.EDMIAppServerAttribute
+Imports GlobalSettingAttribute = DigitalData.Modules.Config.ConfigAttributes.GlobalSettingAttribute
Public Class ConfigManager(Of T)
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 _LogConfig As LogConfig
Private ReadOnly _Logger As Logger
Private ReadOnly _File As FilesystemEx
@@ -24,6 +30,7 @@ Public Class ConfigManager(Of T)
Private ReadOnly _Blueprint As T
Private ReadOnly _BlueprintType As Type
Private ReadOnly _Serializer As XmlSerializer
+ Private _Config As T
Private ReadOnly _ExcludedAttributes = New List(Of Type) From {
GetType(ConnectionStringAttribute),
@@ -59,6 +66,10 @@ Public Class ConfigManager(Of T)
'''
'''
Public ReadOnly Property Config As T
+ Get
+ Return _Config
+ End Get
+ End Property
'''
''' Path to the current user config.
@@ -100,6 +111,38 @@ Public Class ConfigManager(Of T)
''' 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, Optional ApplicationStartupPath As String = "", Optional ForceUserConfig As Boolean = False)
+ If LogConfig Is Nothing Then Throw New ArgumentNullException(NameOf(LogConfig))
+ If String.IsNullOrWhiteSpace(UserConfigPath) Then Throw New ArgumentException("UserConfigPath must be provided", NameOf(UserConfigPath))
+
+ _LogConfig = LogConfig
+ _Logger = LogConfig.GetLogger()
+ _File = New FilesystemEx(_LogConfig)
+
+ _Blueprint = Activator.CreateInstance(Of T)()
+ _BlueprintType = _Blueprint.GetType()
+ _Serializer = New XmlSerializer(_BlueprintType)
+
+ _UserDirectory = _File.CreateDirectory(UserConfigPath)
+ _UserConfigPath = Path.Combine(_UserDirectory, USER_CONFIG_NAME)
+
+ If Not String.IsNullOrWhiteSpace(ComputerConfigPath) Then
+ If IO.File.Exists(ComputerConfigPath) Then
+ _ComputerDirectory = _File.CreateDirectory(ComputerConfigPath, False)
+ Else
+ _ComputerDirectory = ComputerConfigPath
+ End If
+ _ComputerConfigPath = Path.Combine(_ComputerDirectory, COMPUTER_CONFIG_NAME)
+ End If
+
+ _AppConfigDirectory = ApplicationStartupPath
+ If Not String.IsNullOrWhiteSpace(ApplicationStartupPath) Then
+ _AppConfigPath = Path.Combine(ApplicationStartupPath, APP_CONFIG_NAME)
+ End If
+
+ _WriteAllValuesToUserConfig = ForceUserConfig
+
+ _Config = LoadConfig()
+ End Sub
'''
''' Creates a new ConfigManager with a single (user)config path