-
-
Save beppe9000/dc29e69d6b9b18cee88e to your computer and use it in GitHub Desktop.
Testing DataContractSerializer in .Net 4.5.1 - Visual Basic
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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