load default config when config exists but is empty

This commit is contained in:
Jonathan Jenne 2019-02-22 11:41:05 +01:00
parent 39c118308d
commit 19bc39c0ce
4 changed files with 16 additions and 2 deletions

View File

@ -160,6 +160,10 @@ Public Class ConfigManager(Of T)
oConfig = _Serializer.Deserialize(oReader) oConfig = _Serializer.Deserialize(oReader)
End Using End Using
If oConfig Is Nothing Then
oConfig = Activator.CreateInstance(_Blueprint.GetType)
End If
Return oConfig Return oConfig
Catch ex As Exception Catch ex As Exception
_Logger.Error(ex) _Logger.Error(ex)

View File

@ -10,6 +10,7 @@ Public Class ClassService
Public Enum ConnectionTestResult Public Enum ConnectionTestResult
Successful Successful
NotFound NotFound
EmptyURI
Unknown Unknown
End Enum End Enum
@ -57,6 +58,9 @@ Public Class ClassService
Catch ex As EndpointNotFoundException Catch ex As EndpointNotFoundException
_Logger.Error(ex) _Logger.Error(ex)
Return ConnectionTestResult.NotFound Return ConnectionTestResult.NotFound
Catch ex As UriFormatException
_Logger.Error(ex)
Return ConnectionTestResult.EmptyURI
Catch ex As Exception Catch ex As Exception
_Logger.Error(ex) _Logger.Error(ex)
Return ConnectionTestResult.Unknown Return ConnectionTestResult.Unknown

View File

@ -91,7 +91,6 @@ Partial Class frmConfigService
' '
'btnOK 'btnOK
' '
Me.btnOK.DialogResult = System.Windows.Forms.DialogResult.Cancel
Me.btnOK.Location = New System.Drawing.Point(257, 124) Me.btnOK.Location = New System.Drawing.Point(257, 124)
Me.btnOK.Name = "btnOK" Me.btnOK.Name = "btnOK"
Me.btnOK.Size = New System.Drawing.Size(75, 23) Me.btnOK.Size = New System.Drawing.Size(75, 23)

View File

@ -32,6 +32,8 @@
Select Case oResult Select Case oResult
Case ClassService.ConnectionTestResult.NotFound Case ClassService.ConnectionTestResult.NotFound
lblStatus.Text = "Dienst konnte nicht gefunden werden. Bitte überprüfen sie Addresse und Port." lblStatus.Text = "Dienst konnte nicht gefunden werden. Bitte überprüfen sie Addresse und Port."
Case ClassService.ConnectionTestResult.EmptyURI
lblStatus.Text = "Bitte tragen Sie eine gültige Dienst Adresse ein."
Case Else Case Else
lblStatus.Text = "Unbekannter Fehler." lblStatus.Text = "Unbekannter Fehler."
End Select End Select
@ -43,6 +45,11 @@
End Sub End Sub
Private Sub btnOK_Click(sender As Object, e As EventArgs) Handles btnOK.Click Private Sub btnOK_Click(sender As Object, e As EventArgs) Handles btnOK.Click
DialogResult = DialogResult.OK If My.SystemConfigManager.Config.ServiceConnection <> String.Empty Then
DialogResult = DialogResult.OK
Close()
Else
MsgBox("Bitte tragen Sie die Dienst Adresse ein!")
End If
End Sub End Sub
End Class End Class