diff --git a/GUIs.ClientSuite/ClientSuite.vbproj b/GUIs.ClientSuite/ClientSuite.vbproj index a0b1e23c..b7851db2 100644 --- a/GUIs.ClientSuite/ClientSuite.vbproj +++ b/GUIs.ClientSuite/ClientSuite.vbproj @@ -445,6 +445,10 @@ + + {3dcd6d1a-c830-4241-b7e4-27430e7ea483} + LookupControl + {5b1171dc-fffe-4813-a20d-786aae47b320} EDMIAPI @@ -453,10 +457,6 @@ {991d0231-4623-496d-8bd0-9ca906029cbc} Filesystem - - {3DCD6D1A-C830-4241-B7E4-27430E7EA483} - LookupControl - {44982f9b-6116-44e2-85d0-f39650b1ef99} Config diff --git a/Modules.Config/ConfigAttributes.vb b/Modules.Config/ConfigAttributes.vb index d5b64582..672423f2 100644 --- a/Modules.Config/ConfigAttributes.vb +++ b/Modules.Config/ConfigAttributes.vb @@ -2,4 +2,8 @@ Public Class ConnectionStringAttribute Inherits Attribute End Class + + Public Class ConnectionStringTestAttribute + Inherits Attribute + End Class End Class diff --git a/Modules.Config/ConfigManager.vb b/Modules.Config/ConfigManager.vb index c1e9a300..a082ca94 100644 --- a/Modules.Config/ConfigManager.vb +++ b/Modules.Config/ConfigManager.vb @@ -14,7 +14,8 @@ Public Class ConfigManager(Of T) Private ReadOnly _UserPath As String Private ReadOnly _ComputerPath As String - Private _ForceUserConfig As Boolean + Private _ForceUserConfig As Boolean = False + Private _TestMode As Boolean = False ''' ''' The blueprint class from which the default config is created @@ -90,6 +91,14 @@ Public Class ConfigManager(Of T) End Try End Function + ''' + ''' Copies all properties from Source to Target, except those who have an attribute + ''' listed in ExcludedAttributeTypes + ''' + ''' Config Class + ''' Source config object + ''' Target config object + ''' List of Attribute type to exclude Private Sub CopyValues(Of T)(Source As T, Target As T, Optional ExcludedAttributeTypes As List(Of Type) = Nothing) Dim oType As Type = GetType(T) Dim oExcludedAttributeTypes = IIf(IsNothing(ExcludedAttributeTypes), New List(Of Type), ExcludedAttributeTypes) @@ -126,12 +135,7 @@ Public Class ConfigManager(Of T) If File.Exists(_ComputerPath) Then Try Dim oComputerConfig = ReadFromFile(_ComputerPath) - - ' if a computer config exists, copy values - ' from computer config to final config - If Not IsNothing(oComputerConfig) Then - CopyValues(oComputerConfig, Config) - End If + CopyValues(oComputerConfig, Config) Catch ex As Exception _Logger.Error(ex) _Logger.Warn("Computer config could not be loaded!") @@ -151,12 +155,16 @@ Public Class ConfigManager(Of T) ' if user config exists If Not IsNothing(oUserConfig) Then Dim oExcludedAttributes As New List(Of Type) - If Not _ForceUserConfig Then - oExcludedAttributes.Add(GetType(ConnectionStringAttribute)) - End If ' Copy values from user config to final config - CopyValues(oUserConfig, Config, oExcludedAttributes) + If _ForceUserConfig Then + CopyValues(oUserConfig, Config, New List(Of Type)) + Else + CopyValues(oUserConfig, Config, New List(Of Type) From { + GetType(ConnectionStringAttribute), + GetType(ConnectionStringTestAttribute) + }) + End If End If 'Dim oConnectionProperty = TestHasAttribute(oConfig, GetType(ConnectionStringAttribute)) @@ -182,14 +190,14 @@ Public Class ConfigManager(Of T) Return oConfig End Function - Private Function TestHasAttribute(Config As T, AttributeType As Type) As String + Private Function TestHasAttribute(Config As T, AttributeType As Type) As Boolean For Each oProperty As PropertyInfo In Config.GetType.GetProperties() If Attribute.IsDefined(oProperty, GetType(ConnectionStringAttribute)) Then - Return oProperty.Name + Return True End If Next - Return Nothing + Return False End Function ''' diff --git a/Modules.Config/ConfigSample.vb b/Modules.Config/ConfigSample.vb index f6ded688..0f2f7e75 100644 --- a/Modules.Config/ConfigSample.vb +++ b/Modules.Config/ConfigSample.vb @@ -4,4 +4,7 @@ Public Class ConfigSample Public Property ConnectionString As String + + + Public Property ConnectionStringTest As String End Class