WriteSetUpdateToXml method

  1. @override
bool WriteSetUpdateToXml(
  1. EwsServiceXmlWriter writer,
  2. ServiceObject? ewsObject,
  3. String? ownerDictionaryXmlElementName
)
override
Writes the update to XML. The writer. The ews object. Name of the owner dictionary XML element.

Implementation

@override
bool WriteSetUpdateToXml(EwsServiceXmlWriter writer, ServiceObject? ewsObject,
    String? ownerDictionaryXmlElementName) {
  List<String> fieldsToSet = <String>[];

  for (String xmlElementName in this._propertyBag.AddedItems) {
    fieldsToSet.add(xmlElementName);
  }

  for (String xmlElementName in this._propertyBag.ModifiedItems) {
    fieldsToSet.add(xmlElementName);
  }

  for (String xmlElementName in fieldsToSet) {
    writer.WriteStartElement(
        XmlNamespace.Types, ewsObject!.GetSetFieldXmlElementName());

    writer.WriteStartElement(
        XmlNamespace.Types, XmlElementNames.IndexedFieldURI);
    writer.WriteAttributeValue(
        XmlAttributeNames.FieldURI, _GetFieldUri(xmlElementName));
    writer.WriteAttributeValue(XmlAttributeNames.FieldIndex, this.Key);
    writer.WriteEndElement(); // IndexedFieldURI

    writer.WriteStartElement(
        XmlNamespace.Types, ewsObject.GetXmlElementName());
    writer.WriteStartElement(
        XmlNamespace.Types, ownerDictionaryXmlElementName);
    writer.WriteStartElement(XmlNamespace.Types, XmlElementNames.Entry);
    this.WriteAttributesToXml(writer);
    writer.WriteElementValueWithNamespace(XmlNamespace.Types, xmlElementName,
        this._propertyBag[xmlElementName]);
    writer.WriteEndElement(); // Entry
    writer.WriteEndElement(); // ownerDictionaryXmlElementName
    writer.WriteEndElement(); // ewsObject.GetXmlElementName()

    writer.WriteEndElement(); // ewsObject.GetSetFieldXmlElementName()
  }

  for (String xmlElementName in this._propertyBag.RemovedItems) {
    this._InternalWriteDeleteFieldToXml(writer, ewsObject!, xmlElementName);
  }

  return true;
}