开发者

With Protobuf-net, does it allow deserialization reuse existing instances if they are the same?

开发者 https://www.devze.com 2023-01-04 07:02 出处:网络
I\'m using Protobuf-net. Suppose I have a list of Gizmo objects serialized and that each gizmo object reference a Gazoo object. The Gazoo object might be the same object referred by several Gizmo obje

I'm using Protobuf-net. Suppose I have a list of Gizmo objects serialized and that each gizmo object reference a Gazoo object. The Gazoo object might be the same object referred by several Gizmo objects.

How would deserialization work in this situation?

Would I get more than one copies of Gazoos for the same referred one in the gizmo objects?

What I woul开发者_JAVA技巧d expect would be one copy of Gazoo for all the duplicates in the serialized data.


The wire-format defined by google is a tree serializer, not a graph serializer, so object-references are not preserved. However, once I get "v2" shipped, I have some nefarious plans to hack object-reference/graph support into the model - essentially by (in that mode) including additional object-id data. This will make it somewhat tricky to use in interop scenarios, however - so ideally only good for protobuf-net <===> protobuf-net.

But nothing today - you'll get multiple copies, or if you get a circular reference it should explode.


As an update: this is now available in protobuf-net v2, but as an implementation-specific feature outside of the code spec.

0

精彩评论

暂无评论...
验证码 换一张
取 消