Imports System.IO Imports Newtonsoft.Json Imports Pilz.Configuration Imports Pilz.GeneralEventArgs Public Class SimpleConfiguration Public ReadOnly Managers As New ConfigurationManagerList Public Sub New() AddHandler Managers.GettingParentManager, AddressOf Managers_GettingParentManager End Sub Private Sub Managers_GettingParentManager(sender As Object, e As GetValueEventArgs(Of SimpleConfiguration)) If sender Is Managers Then e.Value = Me End If End Sub ''' ''' Writes this instance to a string and return it. ''' ''' The content of the configuration instance as string. Public Function WriteToString() As String Return ConfigurationSerializer.WriteToString(Me) End Function ''' ''' Write this instance to a given stream. ''' ''' The stream where the content should be written to. Public Sub WriteToStream(stream As Stream) ConfigurationSerializer.WriteToStream(Me, stream) End Sub ''' ''' Writes this instance to the given filePath as text file. ''' ''' The file path where the content should be written to. The file will be created or overwritten. Public Sub WriteToFile(filePath As String) ConfigurationSerializer.WriteToFile(Me, filePath) End Sub ''' ''' Reads a configuratin from the given string and returns an instance of it. ''' ''' The type of the configuration class to instance. ''' The content of the configuration as string. ''' Public Shared Function ReadFromString(Of T As SimpleConfiguration)(content As String) As T Return ConfigurationSerializer.ReadFromString(Of T)(content) End Function ''' ''' Read a configuration from the given string and put them to this instance. ''' ''' The content of the configuration as string. Public Sub ReadFromString(content As String) ConfigurationSerializer.ReadFromString(Me, content) End Sub ''' ''' Reads a configuratin from the given string and returns an instance of it. ''' ''' The type of the configuration class to instance. ''' The stream with the content of the configuration. ''' Public Shared Function ReadFromStream(Of T As SimpleConfiguration)(stream As Stream) As T Return ConfigurationSerializer.ReadFromStream(Of T)(stream) End Function ''' ''' Read a configuration from the given string and put them to this instance. ''' ''' The stream with the content of the configuration. Public Sub ReadFromStream(stream As Stream) ConfigurationSerializer.ReadFromStream(Me, stream) End Sub ''' ''' Reads a configuratin from the given string and returns an instance of it. ''' ''' The type of the configuration class to instance. ''' The path to the file with the content of the configuration. ''' Public Shared Function ReadFromFile(Of T As SimpleConfiguration)(filePath As String) As T Return ConfigurationSerializer.ReadFromFile(Of T)(filePath) End Function ''' ''' Read a configuration from the given string and put them to this instance. ''' ''' The path to the file with the content of the configuration. Public Sub ReadFromFile(filePath As String) ConfigurationSerializer.ReadFromFile(Me, filePath) End Sub End Class