How could I serialize/deserialize VesionSet?

var serializer = new XmlSerializer(typeof(VersionSet));

causes InvalidOperationException: To be XML serializable, types which inherit from IEnumerable must have an implementation of Add(System.Object) at all levels of their inheritance hierarchy. Xtensive.Storage.VersionSet does not implement Add(System.Object).

var stream = new MemoryStream();
var serializer = new XmlSerializer(typeof(VersionInfo));
serializer.Serialize(stream, versions.First().Value);

Using this - there are no data of tuple.

Serialization/Deserialization requied for transfer to/from webclient.

This thread was imported from our support forum. The original discussion may contain more detailed answer.

asked Mar 24 '10 at 11:40

pil0t's gravatar image

pil0t
207575763


One Answer:

Alex (Xtensive) wrote:

  1. XmlSerializer capabilities aren't sufficient here. Use NetDataContractSerializer (definitely must work) or DataContractSerializer to do this.

  2. You must have current Session available on deserialization.

P.S. Right now Denis works on N-tier sample for DO4. So we'll show how to transfer the state and apply the operations to Domains today or tomorrow. There are really many non-obvious things you must care about. But in the end everything works.


psulek wrote:

So do i waiting for example. But for now i use Json.NET serialization to string, string to byte[] and compress this byte array with MiniLZO with goood compression rate, maybe better than xml serialization. I select serializing with Json.NET because of silverlight, where NetDataContractSerializer is not supported.

answered Mar 24 '10 at 12:08

Editor's gravatar image

Editor
46154156157

NetDataContractSerializer work, but it produces wery wery ugly xml with a lot of unnecessary data, not for transfer to and from web pages.

Waiting for your example ;)

(Mar 24 '10 at 12:08) pil0t pil0t's gravatar image
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
toggle preview

powered by OSQA