Question

This type is defined in an assembly where I cannot add a reference to protobuf-net:

[StructLayout(LayoutKind.Sequential)]
[XmlType] // for XML or protobuf-net serialization
public struct PointI
{
    public PointI(int x, int y) { X = x; Y = y; }

    [XmlElement(Order = 1)]
    public int X;
    [XmlElement(Order = 2)]
    public int Y;
    ...
}

How can I use ProtoBuf.Meta.RuntimeTypeModel.Default to specify zig-zag storage to optimize output size?

Was it helpful?

Solution

var metaType = RuntimeTypeModel.Default.Add(typeof(PointI), true);
metaType[1].DataFormat = metaType[2].DataFormat = ProtoBuf.DataFormat.ZigZag;

That do ? In other news: mutable structs... bleugh...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top