WriteToXml method

void WriteToXml(
  1. EwsServiceXmlWriter writer
)
Writes the bag's properties to XML. The writer to write the properties to.

Implementation

void WriteToXml(EwsServiceXmlWriter writer) {
  writer.WriteStartElement(
      XmlNamespace.Types, this.Owner!.GetXmlElementName());

  for (PropertyDefinition propertyDefinition in this.Owner!.Schema) {
    // The following test should not be necessary since the property bag prevents
    // properties to be set if they don't have the CanSet flag, but it doesn't hurt...
    if (propertyDefinition.HasFlag(PropertyDefinitionFlags.CanSet,
        writer.Service.RequestedServerVersion)) {
      if (this.Contains(propertyDefinition)) {
        propertyDefinition.WritePropertyValueToXml(
            writer, this, false /* isUpdateOperation */);
      }
    }
  }

  writer.WriteEndElement();
}