Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><code>IXmlSerializable</code> is one option (but not much fun), but it <em>feels</em> like in this case properties offer most of what is wanted without extra work:</p> <pre><code>[Serializable] public class Foo { public string Abc {get;set;} private byte[] bcd; public byte[] Bcd { get {return bcd;} set {/* your code (with `value`) here */ } } } </code></pre> <p>Re the wire format (base64 etc); have you tried just running it through xsd.exe? It might surprise you and get it right... but yes; within <code>IXmlSerializable</code> you will have your choice of <code>ReadContentAsBase64</code>, <code>ReadContentAsBinHex</code>, etc. But it is very ugly; something like (for a <strong>simple</strong> version):</p> <pre><code>[Serializable] public class Foo : IXmlSerializable { public Foo() { } public Foo(string abc, byte[] bcd) { Abc = abc; Bcd = bcd; } public string Abc { get; private set; } public byte[] Bcd { get; private set; } XmlSchema IXmlSerializable.GetSchema() { return null; } void IXmlSerializable.WriteXml(System.Xml.XmlWriter writer) { if (Abc != null) { writer.WriteElementString("Abc", Abc); } if (Bcd != null) { writer.WriteStartElement("Bcd"); writer.WriteBase64(Bcd, 0, Bcd.Length); writer.WriteEndElement(); } } void IXmlSerializable.ReadXml(System.Xml.XmlReader reader) { reader.ReadStartElement(); reader.ReadStartElement("Abc"); Abc = reader.ReadString(); reader.ReadEndElement(); reader.ReadStartElement("Bcd"); MemoryStream ms = null; byte[] buffer = new byte[256]; int bytesRead; while ((bytesRead = reader.ReadContentAsBase64( buffer, 0, buffer.Length)) &gt; 0) { if (ms == null) ms = new MemoryStream(bytesRead); ms.Write(buffer, 0, bytesRead); } if (ms != null) Bcd = ms.ToArray(); reader.ReadEndElement(); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload