42 lines
1.3 KiB
VB.net
42 lines
1.3 KiB
VB.net
Imports System.IO
|
|
Imports System.Xml.Serialization
|
|
|
|
Public Class frmStart
|
|
Private Const ZUGFERD_SERVICE = "ZUGFERD_SERVICE"
|
|
|
|
Private Serializer As XmlSerializer
|
|
Private Configs As New List(Of String) From {
|
|
ZUGFERD_SERVICE
|
|
}
|
|
|
|
|
|
Private Sub frmStart_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
|
ComboBoxEdit1.Properties.Items.Clear()
|
|
ComboBoxEdit1.Properties.Items.AddRange(Configs)
|
|
End Sub
|
|
|
|
Private Sub SimpleButton1_Click(sender As Object, e As EventArgs) Handles SimpleButton1.Click
|
|
Dim oConfigName = ComboBoxEdit1.SelectedItem
|
|
|
|
Select Case oConfigName
|
|
Case ZUGFERD_SERVICE
|
|
MemoEdit1.Text = CreateConfigTemplate(Of DDZUGFeRDService.Config)()
|
|
|
|
Case Else
|
|
MsgBox($"Config {oConfigName} does not exist!", MsgBoxStyle.Exclamation, Text)
|
|
End Select
|
|
End Sub
|
|
|
|
Private Function CreateConfigTemplate(Of T)()
|
|
Serializer = New XmlSerializer(GetType(T))
|
|
Dim oConfig As T = Activator.CreateInstance(GetType(T))
|
|
Dim oBytes As Byte()
|
|
|
|
Using oStream = New MemoryStream()
|
|
Serializer.Serialize(oStream, oConfig)
|
|
oBytes = oStream.ToArray()
|
|
End Using
|
|
|
|
Return System.Text.Encoding.UTF8.GetString(oBytes)
|
|
End Function
|
|
End Class |