Index: ActiviteitenOpvolging/ActiviteitenOpvolging/Form1.Designer.vb =================================================================== diff -u -r1659 -r1669 --- ActiviteitenOpvolging/ActiviteitenOpvolging/Form1.Designer.vb (.../Form1.Designer.vb) (revision 1659) +++ ActiviteitenOpvolging/ActiviteitenOpvolging/Form1.Designer.vb (.../Form1.Designer.vb) (revision 1669) @@ -22,10 +22,17 @@ 'Do not modify it using the code editor. _ Private Sub InitializeComponent() - components = New System.ComponentModel.Container() + Me.SuspendLayout + ' + 'Form1 + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6!, 13!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(800, 450) + Me.Name = "Form1" Me.Text = "Form1" - End Sub + Me.ResumeLayout(false) +End Sub + End Class Index: ActiviteitenOpvolging/ActiviteitenOpvolging/My Project/Resources.resx =================================================================== diff -u -r1659 -r1669 --- ActiviteitenOpvolging/ActiviteitenOpvolging/My Project/Resources.resx (.../Resources.resx) (revision 1659) +++ ActiviteitenOpvolging/ActiviteitenOpvolging/My Project/Resources.resx (.../Resources.resx) (revision 1669) @@ -46,7 +46,7 @@ mimetype: application/x-microsoft.net.object.binary.base64 value : The object must be serialized with - : System.Serialization.Formatters.Binary.BinaryFormatter + : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter : and then encoded with base64 encoding. mimetype: application/x-microsoft.net.object.soap.base64 @@ -60,6 +60,7 @@ : and then encoded with base64 encoding. --> + @@ -68,9 +69,10 @@ - + + @@ -85,9 +87,10 @@ - + + @@ -109,9 +112,9 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 \ No newline at end of file Index: ActiviteitenOpvolging/ActiviteitenOpvolging/configs/ConfigsTextmapper.vb =================================================================== diff -u -r1668 -r1669 --- ActiviteitenOpvolging/ActiviteitenOpvolging/configs/ConfigsTextmapper.vb (.../ConfigsTextmapper.vb) (revision 1668) +++ ActiviteitenOpvolging/ActiviteitenOpvolging/configs/ConfigsTextmapper.vb (.../ConfigsTextmapper.vb) (revision 1669) @@ -34,7 +34,18 @@ Dim lines As String() = allText.Split(New String() {Environment.NewLine}, StringSplitOptions.None) 'Iterate every line, only the important configs. - Return (From line In lines Select line = line.Trim(line) Where Not line.StartsWith("%") And Not line.Equals(String.Empty)).ToList() + + Dim correctLines As New List(Of String) + 'Extract the lines which are not comment lines (doesn't start with '%') and are not empty. + For Each line As String In lines + line = line.Trim() + 'Check if line is valid. + If Not line.StartsWith("%") And Not line.Equals(String.Empty) Then + correctLines.Add(line) + End If + Next + 'Return the correct lines. + Return correctLines Catch ex As ReadOnlyException Throw New ConfigurationException($"File is readonly: '{configFilePath}'") Catch ex As PathTooLongException @@ -52,16 +63,21 @@ ''' ''' Private Function ConvertMultiLineToSingleLine(allText As String) As String + 'Check if it's necessary to run other code. + If Not allText.Contains("__") Then + Return allText + End If + 'Invoke the Match method, all text between and including the 'µ'. - Dim m As Match = Regex.Match(allText, "µ.*µ") + Dim m As Match = Regex.Match(allText, "__[\S\s]*?__") If (m.Success) Then 'If successful, overwrite each multiline from the groups as one line, without the seperator symbols 'µ'. For Each group In m.Groups 'Remove newLines. Dim onelineString = group.Value.Replace(vbCr, String.Empty).Replace(vbLf, String.Empty) 'Remove special characters. - onelineString = onelineString.Replace("µ", String.Empty) + onelineString = onelineString.Replace("__", String.Empty) 'Overwrite multiline entry in text. allText = allText.Replace(m.Value, onelineString) Next Index: ActiviteitenOpvolging/ActiviteitenOpvolging/Form1.vb =================================================================== diff -u -r1659 -r1669 --- ActiviteitenOpvolging/ActiviteitenOpvolging/Form1.vb (.../Form1.vb) (revision 1659) +++ ActiviteitenOpvolging/ActiviteitenOpvolging/Form1.vb (.../Form1.vb) (revision 1669) @@ -1,3 +1,7 @@ -Public Class Form1 +Imports ActiviteitenOpvolging.configs +Public Class Form1 + Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load + dim test = ConfigsLoader.GridLabelNames + End Sub End Class Index: ActiviteitenOpvolging/ActiviteitenOpvolging/configs/ConfigsLoader.vb =================================================================== diff -u -r1667 -r1669 --- ActiviteitenOpvolging/ActiviteitenOpvolging/configs/ConfigsLoader.vb (.../ConfigsLoader.vb) (revision 1667) +++ ActiviteitenOpvolging/ActiviteitenOpvolging/configs/ConfigsLoader.vb (.../ConfigsLoader.vb) (revision 1669) @@ -1,7 +1,8 @@ -Imports System.Security.Policy +Imports System.IO +Imports System.Security.Policy Namespace configs - Public Class ConfigsLoader + Public Module ConfigsLoader Const MaxNumberOfGrids As Integer = 4 Const MaxNumberOfUsers As Integer = 4 @@ -10,7 +11,7 @@ Dim configsTextMapper As New ConfigsTextmapper 'Load the configs that change for every work post. - LoadDynamicConfigLines(configsTextMapper.GetAllValues("c:\users\test.txt")) + LoadDynamicConfigLines(configsTextMapper.GetAllValues(Path.Combine(My.Application.Info.DirectoryPath, "DynamicConfigs.txt"))) ValidateDynamicConfigs() 'Load the general configs. Dim generalConfigLines = configsTextMapper.GetAllValues("c:\users\test.txt") @@ -21,15 +22,6 @@ End Try End Sub -#Region "Dynamic config properties" - Property AppName As String - Property AppId As String - Property NumberOfGrids As Integer - Property GridLabelNames As New List(Of String) - Property SqlQueries As New List(Of String) - Property NumberOfUsers As Integer -#End Region - #Region "General config properties" Property RefreshIntervalMiliseconds As Integer Property RefreshTimeStart As DateTime @@ -71,37 +63,61 @@ Private Function ExtractConfigValue(configLine As String) As String Try 'Everything after the '='. - Return configLine.Substring(configLine.IndexOf("=", StringComparison.Ordinal)).Trim() + Return configLine.Substring(configLine.IndexOf("=", StringComparison.Ordinal) + 1).Trim() Catch ex As Exception Throw New Exception($"Invalid configuration entry. Can't extract the value for the config (the part after the '='): '{configLine}'.") End Try End Function #End Region +#Region "Dynamic configs" +#Region "Properties" + Public ReadOnly Property AppName As String + Public ReadOnly Property AppId As String + Public ReadOnly Property NumberOfGrids As Integer + Private ReadOnly _gridLabelNames As New List(Of String) + Public ReadOnly Property GridLabelNames As List(Of String) + Get + Return New List(Of String)(_gridLabelNames) + End Get + End Property + Private ReadOnly _sqlQueries As New List(Of String) + Public ReadOnly Property SqlQueries As List(Of String) + Get + Return New List(Of String)(_sqlQueries) + End Get + End Property + Public ReadOnly Property NumberOfUsers As Integer +#End Region + ''' ''' Loads in all the present configs specific for a work post. ''' ''' Private Sub LoadDynamicConfigLines(dynamicConfigLines As IReadOnlyCollection(Of String)) - For Each line In dynamicConfigLines - Dim identifier = ExtractConfigIdentifier(line) - Dim value = ExtractConfigValue(line) - If identifier.Equals("AppName") Then - AppName = value - ElseIf identifier.Equals("AppId") Then - AppId = value - ElseIf identifier.Equals("NumberOfGrids") Then - NumberOfGrids = value - ElseIf identifier.Contains("GridLabel") Then - GridLabelNames.Add(value) - ElseIf identifier.Contains("SQL") Then - SqlQueries.Add(value) - ElseIf identifier.Equals("NumberOfUsers") Then - NumberOfUsers = value - Else - Throw New Exception($"Unknown configuration: '{line}'.") - End If - Next + Try + For Each line In dynamicConfigLines + Dim identifier = ExtractConfigIdentifier(line) + Dim value = ExtractConfigValue(line) + If identifier.Equals("AppName") Then + _AppName = value + ElseIf identifier.Equals("AppID") Then + _AppId = value + ElseIf identifier.Equals("NumberOfGrids") Then + _NumberOfGrids = value + ElseIf identifier.Contains("GridLabel") Then + _gridLabelNames.Add(value) + ElseIf identifier.Contains("SQL") Then + _sqlQueries.Add(value) + ElseIf identifier.Equals("NumberOfUsers") Then + _NumberOfUsers = value + Else + Throw New Exception($"Unknown configuration: '{line}'.") + End If + Next + Catch ex As InvalidCastException + Throw New ConfigurationException($"One of the values is an invalid type.{vbNewLine}{ex.Message}") + End Try End Sub ''' @@ -141,5 +157,6 @@ Throw New ConfigurationException($"Number of users is above the maximum of {MaxNumberOfUsers}.") End If End Sub - End Class +#End Region + End Module End Namespace \ No newline at end of file Index: ActiviteitenOpvolging/ActiviteitenOpvolging/ActiviteitenOpvolging.vbproj =================================================================== diff -u -r1664 -r1669 --- ActiviteitenOpvolging/ActiviteitenOpvolging/ActiviteitenOpvolging.vbproj (.../ActiviteitenOpvolging.vbproj) (revision 1664) +++ ActiviteitenOpvolging/ActiviteitenOpvolging/ActiviteitenOpvolging.vbproj (.../ActiviteitenOpvolging.vbproj) (revision 1669) @@ -73,15 +73,19 @@ - + + + + + Form Form1.vb Form - + True @@ -99,6 +103,9 @@ + + Form1.vb + VbMyResourcesResXFileCodeGenerator Resources.Designer.vb Index: ActiviteitenOpvolging/ActiviteitenOpvolging/My Project/Resources.Designer.vb =================================================================== diff -u -r1659 -r1669 --- ActiviteitenOpvolging/ActiviteitenOpvolging/My Project/Resources.Designer.vb (.../Resources.Designer.vb) (revision 1659) +++ ActiviteitenOpvolging/ActiviteitenOpvolging/My Project/Resources.Designer.vb (.../Resources.Designer.vb) (revision 1669) @@ -11,30 +11,31 @@ Option Strict On Option Explicit On +Imports System Namespace My.Resources - + 'This class was auto-generated by the StronglyTypedResourceBuilder 'class via a tool like ResGen or Visual Studio. 'To add or remove a member, edit your .ResX file then rerun ResGen 'with the /str option, or rebuild your VS project. ''' ''' A strongly-typed resource class, for looking up localized strings, etc. ''' - _ + _ Friend Module Resources - + Private resourceMan As Global.System.Resources.ResourceManager - + Private resourceCulture As Global.System.Globalization.CultureInfo - + ''' ''' Returns the cached ResourceManager instance used by this class. ''' - _ + _ Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager Get If Object.ReferenceEquals(resourceMan, Nothing) Then @@ -44,17 +45,17 @@ Return resourceMan End Get End Property - + ''' ''' Overrides the current thread's CurrentUICulture property for all ''' resource lookups using this strongly typed resource class. ''' - _ + _ Friend Property Culture() As Global.System.Globalization.CultureInfo Get Return resourceCulture End Get - Set(ByVal value As Global.System.Globalization.CultureInfo) + Set resourceCulture = value End Set End Property