StreamingContext 的 protobuf-net 等效项
我正在将一些代码从 DataContractSerializer 转换为令人印象深刻的 protobuf-net 序列化器,我真正缺少的一件事是 StreamingContext 传递到我的 OnDeserializing 方法。我真的很想找到一种方法,在反序列化过程中将一些上下文信息传递给我的一些对象。
我的问题:protobuf-net 支持这种使用模式吗?到目前为止,我在对其 API 的调查中还没有找到等效的东西,但我对其设计不是很熟悉,所以可能忽略了一些东西。
I'm translating some code from the DataContractSerializer to the impressive protobuf-net serializer, and one thing that I'm really missing is the StreamingContext passed through to my OnDeserializing methods. I'd really like to find a way to pass a bit of context information through to some of my objects during their deserialization.
My question: is this usage pattern supported in protobuf-net? I haven't found an equivalent so far in my investigation of its APIs, but I'm not very familiar with its design so may have overlooked something.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
支持带有
StreamingContext
的签名,但它当前不包含.Context
(它当前仅声明StreamingContextStates.Persistence< /code> 与
.Context = null
),如果这就是您的意思。我可以通过向序列化/反序列化方法添加重载来支持这一点 - 大概这可以解决它?如果是这样,请在项目网站上记录功能请求。由于在这种情况下它已经支持
StreamingContext
,所以听起来并不难。The signature with a
StreamingContext
is supported, but it does not currently include the.Context
(it currently just announcesStreamingContextStates.Persistence
with.Context = null
), if that is what you mean.I could support that by adding an overload to the serialize/deserialize methods - presumably that would solve it?If so, please log a feature request on the project site. Since it already supports
StreamingContext
in this scenario, it doesn't sound hard.