M
Monty
Hello, I have a singleton settings class (.Net 2.0 framework) that I
serialize/deserialize to XML. On my settings class is a shared list of
integers. If I have two numbers in my list and I deserialize my class
successive times, the count of integers in my list grows by 2 each time when
I would expect it to remain at 2. When I run this code (below) and click the
button multiple times, my immediate window shows the following results:
2
4
6
8
10
Can anyone tell me what's going on here? TIA.
Imports System.Xml.Serialization
<Serializable()> _
Public Class cMySettings
Public Shared UserIDs As List(Of Integer)
Public Property zUserIDs() As List(Of Integer)
Get
Return UserIDs
End Get
Set(ByVal value As List(Of Integer))
UserIDs = value
End Set
End Property
End Class
Public Class Form1
Private Const sXML As String = _
"<?xml version=""1.0"" encoding=""utf-16""?> <cMySettings> " & _
"<zUserIDs><int>1</int><int>2</int></zUserIDs></cMySettings>"
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim myStream As New System.IO.StringReader(sXML)
Dim serializer As New
System.Xml.Serialization.XmlSerializer(GetType(cMySettings))
serializer.Deserialize(myStream)
Debug.Print(cMySettings.UserIDs.Count)
End Sub
End Class
serialize/deserialize to XML. On my settings class is a shared list of
integers. If I have two numbers in my list and I deserialize my class
successive times, the count of integers in my list grows by 2 each time when
I would expect it to remain at 2. When I run this code (below) and click the
button multiple times, my immediate window shows the following results:
2
4
6
8
10
Can anyone tell me what's going on here? TIA.
Imports System.Xml.Serialization
<Serializable()> _
Public Class cMySettings
Public Shared UserIDs As List(Of Integer)
Public Property zUserIDs() As List(Of Integer)
Get
Return UserIDs
End Get
Set(ByVal value As List(Of Integer))
UserIDs = value
End Set
End Property
End Class
Public Class Form1
Private Const sXML As String = _
"<?xml version=""1.0"" encoding=""utf-16""?> <cMySettings> " & _
"<zUserIDs><int>1</int><int>2</int></zUserIDs></cMySettings>"
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim myStream As New System.IO.StringReader(sXML)
Dim serializer As New
System.Xml.Serialization.XmlSerializer(GetType(cMySettings))
serializer.Deserialize(myStream)
Debug.Print(cMySettings.UserIDs.Count)
End Sub
End Class