/// <summary> /// Writes an EWS SetUpdate opeartion for the specified property. /// </summary> /// <param name="writer">The writer to write the update to.</param> /// <param name="propertyDefinition">The property fro which to write the update.</param> private void WriteSetUpdateToXml(EwsServiceXmlWriter writer, PropertyDefinition propertyDefinition) { // The following test should not be necessary since the property bag prevents // properties to be updated if they don't have the CanUpdate flag, but it // doesn't hurt... if (propertyDefinition.HasFlag(PropertyDefinitionFlags.CanUpdate)) { object propertyValue = this[propertyDefinition]; bool handled = false; ICustomUpdateSerializer updateSerializer = propertyValue as ICustomUpdateSerializer; if (updateSerializer != null) { handled = updateSerializer.WriteSetUpdateToXml( writer, this.Owner, propertyDefinition); } if (!handled) { writer.WriteStartElement(XmlNamespace.Types, this.Owner.GetSetFieldXmlElementName()); propertyDefinition.WriteToXml(writer); writer.WriteStartElement(XmlNamespace.Types, this.Owner.GetXmlElementName()); propertyDefinition.WritePropertyValueToXml(writer, this, true /* isUpdateOperation */); writer.WriteEndElement(); writer.WriteEndElement(); } } }
/// <summary> /// Writes an EWS DeleteUpdate opeartion for the specified property. /// </summary> /// <param name="writer">The writer to write the update to.</param> /// <param name="propertyDefinition">The property fro which to write the update.</param> /// <param name="propertyValue">The current value of the property.</param> private void WriteDeleteUpdateToXml( EwsServiceXmlWriter writer, PropertyDefinition propertyDefinition, object propertyValue) { // The following test should not be necessary since the property bag prevents // properties to be deleted (set to null) if they don't have the CanDelete flag, // but it doesn't hurt... if (propertyDefinition.HasFlag(PropertyDefinitionFlags.CanDelete)) { bool handled = false; ICustomUpdateSerializer updateSerializer = propertyValue as ICustomUpdateSerializer; if (updateSerializer != null) { handled = updateSerializer.WriteDeleteUpdateToXml(writer, this.Owner); } if (!handled) { writer.WriteStartElement(XmlNamespace.Types, this.Owner.GetDeleteFieldXmlElementName()); propertyDefinition.WriteToXml(writer); writer.WriteEndElement(); } } }
/// <summary> /// Writes the set update to json. /// </summary> /// <param name="jsonUpdates">The json updates.</param> /// <param name="propertyDefinition">The property definition.</param> /// <param name="service">The service.</param> private void WriteSetUpdateToJson(List <JsonObject> jsonUpdates, PropertyDefinition propertyDefinition, ExchangeService service) { // The following test should not be necessary since the property bag prevents // properties to be updated if they don't have the CanUpdate flag, but it // doesn't hurt... if (propertyDefinition.HasFlag(PropertyDefinitionFlags.CanUpdate)) { object propertyValue = this[propertyDefinition]; bool handled = false; ICustomUpdateSerializer updateSerializer = propertyValue as ICustomUpdateSerializer; if (updateSerializer != null) { handled = updateSerializer.WriteSetUpdateToJson( service, this.Owner, propertyDefinition, jsonUpdates); } if (!handled) { JsonObject jsonUpdate = CreateJsonSetUpdate(propertyDefinition, service, this.Owner, this); jsonUpdates.Add(jsonUpdate); } } }