/// <summary> /// Método acionad quando for escreve o contúdo do corpo. /// </summary> /// <param name="writer"></param> protected override void OnWriteBodyContents(System.Xml.XmlDictionaryWriter writer) { writer.WriteStartElement("root"); writer.WriteAttributeString("type", "object"); XElement root = _exMsg.Root; foreach (XElement el in root.Descendants()) { writer.WriteStartElement(el.Name.ToString()); writer.WriteAttributeString("type", "string"); writer.WriteString(el.Value.ToString()); writer.WriteEndElement(); } writer.WriteEndElement(); }
/// <summary> /// Método acionad quando for escreve o contúdo do corpo. /// </summary> /// <param name="writer"></param> protected override void OnWriteBodyContents(System.Xml.XmlDictionaryWriter writer) { writer.WriteStartElement("root"); writer.WriteAttributeString("type", "object"); WriteException(writer, _exception); writer.WriteEndElement(); }
private void WriteException(System.Xml.XmlDictionaryWriter writer, Exception exception) { writer.WriteStartElement("type"); writer.WriteAttributeString("type", "string"); writer.WriteString(exception.GetType().Name); writer.WriteEndElement(); writer.WriteStartElement("error"); writer.WriteAttributeString("type", "string"); writer.WriteString(exception.Message); writer.WriteEndElement(); if (exception.InnerException != null) { writer.WriteStartElement("inner"); writer.WriteAttributeString("type", "object"); WriteException(writer, exception.InnerException); writer.WriteEndElement(); } }
protected override void OnWriteHeaderContents(System.Xml.XmlDictionaryWriter writer, MessageVersion messageVersion) { if (_queryParts != null) { foreach (var part in _queryParts) { writer.WriteStartElement(QueryOptionElementName); writer.WriteAttributeString(QueryNameAttribute, part.QueryOperator); writer.WriteAttributeString(QueryValueAttribute, part.Expression); writer.WriteEndElement(); } } if (_includeTotalCount == true) { writer.WriteStartElement(QueryOptionElementName); writer.WriteAttributeString(QueryNameAttribute, QueryIncludeTotalCountOption); writer.WriteAttributeString(QueryValueAttribute, "true"); writer.WriteEndElement(); } }
protected override void OnWriteStartHeader( System.Xml.XmlDictionaryWriter writer, MessageVersion messageVersion) { base.OnWriteStartHeader(writer, messageVersion); // Write your custom XML using the XmlDictionaryClass: //TODO: add the 'param' XML namespace to the writer... //TODO: add the container element with something like this: writer.WriteElementString("SaglikNetParameters", "param", ""); writer.WriteElementString("parameter", "param", "2"); writer.WriteAttributeString("name", "", "islemKodu"); //TODO: complete the rest of the XML ... }
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> /// 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); } } }