'' ------------------------------------------------------------------------------ '' '' Generated by Xsd2Code++. Version 6.0.0.0. www.xsd2code.com '' {"TargetFramework":"Net48","NameSpace":"SuccessResponse_v2_0","Language":"VisualBasic","Properties":{},"XmlAttribute":{"Enabled":true},"ClassParams":{},"Serialization":{"ShouldSerialize":{},"AdditionalSerializers":{},"XmlSerializerEvent":{},"XmlOutput":{"Formating":true},"JsonOutput":{},"Enabled":true},"Miscellaneous":{}} '' '' ------------------------------------------------------------------------------ #Disable Warning Imports System Imports System.Diagnostics Imports System.Xml.Serialization Imports System.Runtime.Serialization Imports System.Collections Imports System.Xml.Schema Imports System.ComponentModel Imports System.Xml Imports System.IO Imports System.Text Imports System.Collections.Generic Namespace SuccessResponse_v2_0 Partial Public Class SuccessResponse #Region "Private fields" Private _message As List(Of MessageType) Private _acceptedTime As Date Private _responseData As System.Xml.XmlElement Private Shared _serializerXml As XmlSerializer #End Region Public Sub New() MyBase.New Me._message = New List(Of MessageType)() End Sub Public Property Message() As List(Of MessageType) Get Return Me._message End Get Set Me._message = Value End Set End Property Public Property AcceptedTime() As Date Get Return Me._acceptedTime End Get Set Me._acceptedTime = Value End Set End Property Public Property ResponseData() As System.Xml.XmlElement Get Return Me._responseData End Get Set Me._responseData = Value End Set End Property Private Shared ReadOnly Property SerializerXml() As XmlSerializer Get If (_serializerXml Is Nothing) Then _serializerXml = New XmlSerializerFactory().CreateSerializer(GetType(SuccessResponse)) End If Return _serializerXml End Get End Property #Region "Serialize/Deserialize" ''' ''' Serialize SuccessResponse object ''' ''' XML value Public Overridable Function Serialize() As String Dim streamReader As StreamReader = Nothing Dim memoryStream As MemoryStream = Nothing Try memoryStream = New MemoryStream() Dim xmlWriterSettings As System.Xml.XmlWriterSettings = New System.Xml.XmlWriterSettings() xmlWriterSettings.Indent = True xmlWriterSettings.IndentChars = " " Dim xmlWriter As System.Xml.XmlWriter = XmlWriter.Create(memoryStream, xmlWriterSettings) SerializerXml.Serialize(xmlWriter, Me) memoryStream.Seek(0, SeekOrigin.Begin) streamReader = New StreamReader(memoryStream) Return streamReader.ReadToEnd Finally If (Not (streamReader) Is Nothing) Then streamReader.Dispose() End If If (Not (memoryStream) Is Nothing) Then memoryStream.Dispose() End If End Try End Function ''' ''' Deserializes SuccessResponse object ''' ''' string to deserialize ''' Output SuccessResponse object ''' output Exception value if deserialize failed ''' true if this Serializer can deserialize the object; otherwise, false Public Overloads Shared Function Deserialize(ByVal input As String, ByRef obj As SuccessResponse, ByRef exception As System.Exception) As Boolean exception = Nothing obj = CType(Nothing, SuccessResponse) Try obj = Deserialize(input) Return True Catch ex As System.Exception exception = ex Return False End Try End Function Public Overloads Shared Function Deserialize(ByVal input As String, ByRef obj As SuccessResponse) As Boolean Dim exception As System.Exception = Nothing Return Deserialize(input, obj, exception) End Function Public Overloads Shared Function Deserialize(ByVal input As String) As SuccessResponse Dim stringReader As StringReader = Nothing Try stringReader = New StringReader(input) Return CType(SerializerXml.Deserialize(XmlReader.Create(stringReader)), SuccessResponse) Finally If (Not (stringReader) Is Nothing) Then stringReader.Dispose() End If End Try End Function Public Overloads Shared Function Deserialize(ByVal s As Stream) As SuccessResponse Return CType(SerializerXml.Deserialize(s), SuccessResponse) End Function #End Region ''' ''' Serializes current SuccessResponse object into file ''' ''' full path of outupt xml file ''' output Exception value if failed ''' true if can serialize and save into file; otherwise, false Public Overridable Overloads Function SaveToFile(ByVal fileName As String, ByRef exception As System.Exception) As Boolean exception = Nothing Try SaveToFile(fileName) Return True Catch e As System.Exception exception = e Return False End Try End Function Public Overridable Overloads Sub SaveToFile(ByVal fileName As String) Dim streamWriter As StreamWriter = Nothing Try Dim dataString As String = Serialize() Dim outputFile As FileInfo = New FileInfo(fileName) streamWriter = outputFile.CreateText streamWriter.WriteLine(dataString) streamWriter.Close() Finally If (Not (streamWriter) Is Nothing) Then streamWriter.Dispose() End If End Try End Sub ''' ''' Deserializes xml markup from file into an SuccessResponse object ''' ''' File to load and deserialize ''' Output SuccessResponse object ''' output Exception value if deserialize failed ''' true if this Serializer can deserialize the object; otherwise, false Public Overloads Shared Function LoadFromFile(ByVal fileName As String, ByRef obj As SuccessResponse, ByRef exception As System.Exception) As Boolean exception = Nothing obj = CType(Nothing, SuccessResponse) Try obj = LoadFromFile(fileName) Return True Catch ex As System.Exception exception = ex Return False End Try End Function Public Overloads Shared Function LoadFromFile(ByVal fileName As String, ByRef obj As SuccessResponse) As Boolean Dim exception As System.Exception = Nothing Return LoadFromFile(fileName, obj, exception) End Function Public Overloads Shared Function LoadFromFile(ByVal fileName As String) As SuccessResponse Dim file As FileStream = Nothing Dim sr As StreamReader = Nothing Try file = New FileStream(fileName, FileMode.Open, FileAccess.Read) sr = New StreamReader(file) Dim dataString As String = sr.ReadToEnd sr.Close() file.Close() Return Deserialize(dataString) Finally If (Not (file) Is Nothing) Then file.Dispose() End If If (Not (sr) Is Nothing) Then sr.Dispose() End If End Try End Function End Class Partial Public Class MessageType #Region "Private fields" Private _code As String Private _lang As String Private _value As String Private Shared _serializerXml As XmlSerializer #End Region Public Property code() As String Get Return Me._code End Get Set Me._code = Value End Set End Property Public Property lang() As String Get Return Me._lang End Get Set Me._lang = Value End Set End Property Public Property Value() As String Get Return Me._value End Get Set Me._value = Value End Set End Property Private Shared ReadOnly Property SerializerXml() As XmlSerializer Get If (_serializerXml Is Nothing) Then _serializerXml = New XmlSerializerFactory().CreateSerializer(GetType(MessageType)) End If Return _serializerXml End Get End Property #Region "Serialize/Deserialize" ''' ''' Serialize MessageType object ''' ''' XML value Public Overridable Function Serialize() As String Dim streamReader As StreamReader = Nothing Dim memoryStream As MemoryStream = Nothing Try memoryStream = New MemoryStream() Dim xmlWriterSettings As System.Xml.XmlWriterSettings = New System.Xml.XmlWriterSettings() xmlWriterSettings.Indent = True xmlWriterSettings.IndentChars = " " Dim xmlWriter As System.Xml.XmlWriter = XmlWriter.Create(memoryStream, xmlWriterSettings) SerializerXml.Serialize(xmlWriter, Me) memoryStream.Seek(0, SeekOrigin.Begin) streamReader = New StreamReader(memoryStream) Return streamReader.ReadToEnd Finally If (Not (streamReader) Is Nothing) Then streamReader.Dispose() End If If (Not (memoryStream) Is Nothing) Then memoryStream.Dispose() End If End Try End Function ''' ''' Deserializes MessageType object ''' ''' string to deserialize ''' Output MessageType object ''' output Exception value if deserialize failed ''' true if this Serializer can deserialize the object; otherwise, false Public Overloads Shared Function Deserialize(ByVal input As String, ByRef obj As MessageType, ByRef exception As System.Exception) As Boolean exception = Nothing obj = CType(Nothing, MessageType) Try obj = Deserialize(input) Return True Catch ex As System.Exception exception = ex Return False End Try End Function Public Overloads Shared Function Deserialize(ByVal input As String, ByRef obj As MessageType) As Boolean Dim exception As System.Exception = Nothing Return Deserialize(input, obj, exception) End Function Public Overloads Shared Function Deserialize(ByVal input As String) As MessageType Dim stringReader As StringReader = Nothing Try stringReader = New StringReader(input) Return CType(SerializerXml.Deserialize(XmlReader.Create(stringReader)), MessageType) Finally If (Not (stringReader) Is Nothing) Then stringReader.Dispose() End If End Try End Function Public Overloads Shared Function Deserialize(ByVal s As Stream) As MessageType Return CType(SerializerXml.Deserialize(s), MessageType) End Function #End Region ''' ''' Serializes current MessageType object into file ''' ''' full path of outupt xml file ''' output Exception value if failed ''' true if can serialize and save into file; otherwise, false Public Overridable Overloads Function SaveToFile(ByVal fileName As String, ByRef exception As System.Exception) As Boolean exception = Nothing Try SaveToFile(fileName) Return True Catch e As System.Exception exception = e Return False End Try End Function Public Overridable Overloads Sub SaveToFile(ByVal fileName As String) Dim streamWriter As StreamWriter = Nothing Try Dim dataString As String = Serialize() Dim outputFile As FileInfo = New FileInfo(fileName) streamWriter = outputFile.CreateText streamWriter.WriteLine(dataString) streamWriter.Close() Finally If (Not (streamWriter) Is Nothing) Then streamWriter.Dispose() End If End Try End Sub ''' ''' Deserializes xml markup from file into an MessageType object ''' ''' File to load and deserialize ''' Output MessageType object ''' output Exception value if deserialize failed ''' true if this Serializer can deserialize the object; otherwise, false Public Overloads Shared Function LoadFromFile(ByVal fileName As String, ByRef obj As MessageType, ByRef exception As System.Exception) As Boolean exception = Nothing obj = CType(Nothing, MessageType) Try obj = LoadFromFile(fileName) Return True Catch ex As System.Exception exception = ex Return False End Try End Function Public Overloads Shared Function LoadFromFile(ByVal fileName As String, ByRef obj As MessageType) As Boolean Dim exception As System.Exception = Nothing Return LoadFromFile(fileName, obj, exception) End Function Public Overloads Shared Function LoadFromFile(ByVal fileName As String) As MessageType Dim file As FileStream = Nothing Dim sr As StreamReader = Nothing Try file = New FileStream(fileName, FileMode.Open, FileAccess.Read) sr = New StreamReader(file) Dim dataString As String = sr.ReadToEnd sr.Close() file.Close() Return Deserialize(dataString) Finally If (Not (file) Is Nothing) Then file.Dispose() End If If (Not (sr) Is Nothing) Then sr.Dispose() End If End Try End Function End Class End Namespace #Enable Warning