protobuf-net 异常:没有为类型定义序列化器:System.Xml.XmlDocument
如何序列化包含 XmlDocument 类型属性的对象?:
[ProtoContract]
public class Foo
{
[ProtoMember(1)]
public XmlDocument Bar { get; set; }
}
How to serialize an object which contains property of XmlDocument type?:
[ProtoContract]
public class Foo
{
[ProtoMember(1)]
public XmlDocument Bar { get; set; }
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
作为字符串;例如:
我想这可以自动处理,但是......将xml打包在protobuf中似乎已经闻到了一点冗余/内部平台效应的味道。因此,我不确定我是否想通过添加直接库支持来鼓励;p
如果您的模型中有很多 xml 文档,那么 - 好吧,首先 protobuf 可能不会给你带来太多好处,但其次:可能可以在 v2 中为
XmlDocument
挂钩一个“代理”;这可能会为每个文档增加 2 个字节的开销,但如果您有 xml,那可能不是最大的问题。As a string; for example:
I guess this could be handled automatically, but... packing xml inside protobuf already seems to smell a bit of redundancy / inner-platform-effect. I As such, I'm not sure that it is something I want to encourage by adding direct library support ;p
If you have lots of xml-documents in your model, then - well, firstly protobuf probably isn't going to gain you much, but secondly : it is probably possible to hook a "surrogate" for
XmlDocument
in v2; this will probably add 2 bytes overhead per doc, but if you have xml that probably isn't your biggest problem.