Setting BinaryFormatter.TypeFormat appears to have no effect

372 Views Asked by At

So I'm serializing some stuff, and I notice that in the BinaryFormatter docs, it mentions that you can improve performance and reduce file size by setting the TypeFormat property to FormatterTypeStyle.TypesWhenNeeded, or FormatterTypeStyle.XsdString.

I've tried both - and OR'ing them together as well - however the size of my resultant file has remained stubbornly identical. Peeking at the contents, I noticed a lot of type strings there as well. (Before anyone asks, before all this the property was set to FormatterTypeStyle.TypesAlways)

I'm using a version of Mono that effectively supports .NET 3.5. It might be something to do with that, but I'd like to confirm that there's not something else I've missed

Thanks in advance for any help

1

There are 1 best solutions below

0
On

I did something like sending a textbuffer to firebird blob to the buffer serializer, this way:

protected Gtk.TextBuffer deserealizar (byte[] datos,TextBuffer txtBuffer)
{
    Atom serialFormat = txtBuffer.RegisterDeserializeTagset(null); 
    ulong datostamano = (ulong) datos.LongLength; 
    TextIter start = txtBuffer.StartIter; 
    txtBuffer.Deserialize(txtBuffer, serialFormat, ref start, datos, datostamano);
    return txtBuffer;
}

protected byte[] serializar(TextBuffer buffer)
{
    TextIter inicio, final;
    buffer.GetBounds(out inicio, out final); 
    Atom serialFormat = buffer.RegisterDeserializeTagset(null);
    byte[] datos = buffer.Serialize(buffer, serialFormat, inicio, final);
    return datos;
}

Hope this helps.