Skip to content

Instantly share code, notes, and snippets.

@beppe9000
Forked from theburningmonk/DCSerializerTest.cs
Created February 11, 2016 19:24
Show Gist options
  • Save beppe9000/dc29e69d6b9b18cee88e to your computer and use it in GitHub Desktop.
Save beppe9000/dc29e69d6b9b18cee88e to your computer and use it in GitHub Desktop.
Testing DataContractSerializer in .Net 4.5.1 - Visual Basic
Imports System.Collections.Generic
Imports System.Linq
Imports System.Text
Imports System.Threading.Tasks
Imports System.Runtime.Serialization
Imports System.IO
Imports System.Xml
Namespace DCSerializerTest
<DataContract> _
Public Class KeywordFunctionMap
<DataMember> _
Public Property Map() As Dictionary(Of String, String)
Get
Return m_Map
End Get
Set
m_Map = Value
End Set
End Property
Private m_Map As Dictionary(Of String, String)
Public Sub New()
Map = New Dictionary(Of String, String)()
End Sub
End Class
Class Program
Private Shared Sub Main(args As String())
Dim serializer = New DataContractSerializer(GetType(KeywordFunctionMap))
Dim xmlString As String
Dim obj = New KeywordFunctionMap()
obj.Map.Add("1", "one")
Using sw = New StringWriter()
Using writer = New XmlTextWriter(sw)
writer.Formatting = Formatting.Indented
serializer.WriteObject(writer, obj)
writer.Flush()
xmlString = sw.ToString()
End Using
End Using
Console.WriteLine(xmlString)
Console.ReadKey()
End Sub
End Class
End Namespace
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment