添加其他元素到 DataContractSerializer 的输出
我正在序列化一个对象(使用 DataContractSerializer),该对象具有附加数据,一种“附加属性”,不绑定到 clr 属性。当然,序列化时我只获得 clr-properties。我正在寻找一种序列化和反序列化附加数据的方法,而不必放弃 DataContractSerializer。
我已经尝试过 IExtensibleDataObject 因为它似乎几乎正是我所追求的。但我似乎无法从 ExtensionDataObject 读取或写入任何数据。
我还可以研究其他方法吗?
I'm serializing an object (using DataContractSerializer) that have additional data, a kind of "attached properties", that's not bound to clr-properties. When serializing I only get the clr-properties of course. I'm looking for a method of both serializing and deserializing additional data without having to give up DataContractSerializer.
I have experimented with IExtensibleDataObject since it seem to be almost exactly what I'm after. But I can't seem to read or write any data from the ExtensionDataObject.
Any other method I could investigate?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您正在寻找的是 IExtensibleDataObject。请参阅以下资源寻求帮助。
博客文章 -- WCF可扩展性 - 其他序列化扩展
向前兼容的数据协定
数据协定版本控制< /a>
I think what you're looking for is IExtensibleDataObject. See the following resources for help.
Blog post -- WCF Extensibility – Other Serialization Extensions
Forward-Compatible Data Contracts
Data Contract Versioning