public override void WriteObjectContent(System.Xml.XmlDictionaryWriter writer, object graph) { if (graph == null) { writer.WriteAttributeString("nil", "true"); } else { using (MemoryStream ms = new MemoryStream()) { Serializer.Serialize <T>(ms, (T)graph); byte[] buffer = ms.GetBuffer(); writer.WriteBase64(buffer, 0, (int)ms.Length); } } }
/// <summary> /// Write body contents /// </summary> protected override void OnWriteBodyContents(System.Xml.XmlDictionaryWriter writer) { writer.WriteStartDocument(); using (MemoryStream ms = new MemoryStream()) { using (Stream gzs = this.m_compressor.CreateCompressionStream(ms)) { gzs.Write(this.m_data, 0, this.m_data.Length); gzs.Flush(); } writer.WriteStartElement("Binary"); byte[] arr = ms.ToArray(); writer.WriteBase64(arr, 0, arr.Length); writer.WriteEndElement(); } writer.WriteEndDocument(); }
/// <summary> /// Writes the body of an object in the output /// </summary> public override void WriteObjectContent(System.Xml.XmlDictionaryWriter writer, object graph) { if (graph == null) { writer.WriteAttributeString("nil", "true"); } else { using (MemoryStream ms = new MemoryStream()) { using (ProtoWriter protoWriter = new ProtoWriter(ms, model, null)) { model.Serialize(key, graph, protoWriter); } byte[] buffer = ms.GetBuffer(); writer.WriteBase64(buffer, 0, (int)ms.Length); } } }