使用 Protobuf-net,如果现有实例相同,它是否允许反序列化重用它们?

发布于 2024-09-05 21:30:32 字数 221 浏览 1 评论 0原文

我正在使用 Protobuf-net。假设我有一个序列化的 Gizmo 对象列表,并且每个 Gizmo 对象引用一个 Gazoo 对象。 Gazoo 对象可能是多个 Gizmo 对象引用的同一对象。

在这种情况下反序列化将如何工作?

对于 gizmo 对象中相同的引用副本,我是否会获得不止一份 Gazoos 副本?

我期望的是一份 Gazoo 副本用于序列化数据中的所有重复项。

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 would expect would be one copy of Gazoo for all the duplicates in the serialized data.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

虐人心 2024-09-12 21:30:32

谷歌定义的有线格式是序列化器,而不是序列化器,因此对象引用被保留。然而,一旦我发布了“v2”,我就有了一些邪恶的计划,将对象引用/图形支持侵入到模型中——本质上是通过(在该模式下)包含额外的对象 ID 数据。然而,这使其在互操作场景中使用起来有些棘手 - 因此理想情况下仅适用于 protobuf-net <===> protobuf-net。

但今天什么也没有——你会得到多个副本,或者如果你得到一个循环引用,它应该会爆炸。


作为更新:现在可以在 protobuf-net v2 中使用,但作为代码规范外部的特定于实现的功能。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文