c# - protobuf-net exception: No serializer defined for type: System.Xml.XmlDocument -


how serialize object contains property of xmldocument type?:

[protocontract] public class foo {     [protomember(1)]      public xmldocument bar { get; set; } } 

as string; example:

[protocontract] public class foo {     public xmldocument bar { get; set; }     [protomember(1)]     private string barserialized {         { return bar == null ? null : bar.outerxml; }         set {             if (value == null) { bar = null; }             else {                 var tmp = new xmldocument();                 tmp.loadxml(value);                 bar = tmp;             }         }     } } 

i guess could handled automatically, but... packing xml inside protobuf seems smell bit of redundancy / inner-platform-effect. such, i'm not sure want encourage adding direct library support ;p

if have lots of xml-documents in model, - well, firstly protobuf isn't going gain much, secondly : possible hook "surrogate" xmldocument in v2; add 2 bytes overhead per doc, if have xml isn't biggest problem.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -