WriteElementsToXml method

  1. @override
void WriteElementsToXml(
  1. EwsServiceXmlWriter writer
)
override
Writes XML elements. The writer.

Implementation

@override
void WriteElementsToXml(EwsServiceXmlWriter writer) {
  if (BodyType != null || AdditionalProperties.isNotEmpty) {
    writer.WriteStartElement(
      XmlNamespace.Messages,
      XmlElementNames.AttachmentShape,
    );

    if (BodyType != null) {
      writer.WriteElementValueWithNamespace(
        XmlNamespace.Types,
        XmlElementNames.BodyType,
        BodyType,
      );
    }

    if (AdditionalProperties.isNotEmpty) {
      PropertySet.WriteAdditionalPropertiesToXml(
        writer,
        AdditionalProperties,
      );
    }

    writer.WriteEndElement(); // AttachmentShape
  }

  writer.WriteStartElement(
    XmlNamespace.Messages,
    XmlElementNames.AttachmentIds,
  );

  for (Attachment attachment in Attachments) {
    _WriteAttachmentIdXml(writer, attachment.Id);
  }

  for (String attachmentId in AttachmentIds) {
    _WriteAttachmentIdXml(writer, attachmentId);
  }

  writer.WriteEndElement();
}