When I run the xmlserializer on my class, it does not output the property I have specified for my nested observable collection. I have made sure it is public and have ensured it has a setter but it just isn't getting serialised.
Running the xmlserializer produces this:
<ArrayOfArrayOfNote>
<ArrayOfNote>
<Note>
(Many Properties of Note)
</Note>
<Note>
(Many Properties of Note)
</Note>
<ArrayOfNote>
<ArrayOfNote>
<Note>
(Many Properties of Note)
</Note>
<Note>
(Many Properties of Note)
</Note>
<ArrayOfNote>
</ArrayOfArrayOfNote>
When I am expecting it to produce something like this:
<ArrayOfArrayOfNote>
<ArrayOfNote>
<Title>SomeTitle</Title>
<Note>
(Many Properties of Note)
</Note>
<Note>
(Many Properties of Note)
</Note>
<ArrayOfNote>
<ArrayOfNote>
<Title>SomeTitle</Title>
<Note>
(Many Properties of Note)
</Note>
<Note>
(Many Properties of Note)
</Note>
<ArrayOfNote>
</ArrayOfArrayOfNote>
This is the code I am using for the xmlserializer (which I believe isn't the problem)
XmlSerializer serialiser = new XmlSerializer(typeof(NoteBookList));
TextWriter writer = new StreamWriter(@"Notes.xml");
serialiser.Serialize(writer, modules);
writer.Close();
This is the class that is not serialized as I am expecting
[Serializable]
public class NoteBook : ObservableCollection<Note>
{
public NoteBook()
{
}
public NoteBook(string title)
{
Title = title;
}
public string Title { get; set; }
}
Thanks!