I have binary serialized objects in a database. They are serialized with protobuf. Now I need to generate some viewer to see the contents of the database. So, I read the stream from the database and deserialize it back to the objects. It works, and the result is a list of objects:
var dbData = readData(someType);
Now I would like to save this list of objects in a file to see the contents of the database. I thought it was best to save it in xml. So I tried:
var serializer = new XmlSerializer(dbData.GetType());
But I get an error: I can not deserialize the type "My.Entities.IdBase", because it contains the property "Key", which does not have a public setter.
Now what? I cannot change class definitions to have setters. Should I save objects instead of json or plain text? Or should I extract all the properties and values and save them in some xml? Any code sample?
source
share