/// <summary> /// Writes the update to XML. /// </summary> /// <param name="writer">The writer.</param> /// <param name="ewsObject">The ews object.</param> /// <param name="propertyDefinition">Property definition.</param> /// <returns> /// True if property generated serialization. /// </returns> bool ICustomUpdateSerializer.WriteSetUpdateToXml( EwsServiceXmlWriter writer, ServiceObject ewsObject, PropertyDefinition propertyDefinition) { List <ExtendedProperty> propertiesToSet = new List <ExtendedProperty>(); propertiesToSet.AddRange(this.AddedItems); propertiesToSet.AddRange(this.ModifiedItems); foreach (ExtendedProperty extendedProperty in propertiesToSet) { writer.WriteStartElement(XmlNamespace.Types, ewsObject.GetSetFieldXmlElementName()); extendedProperty.PropertyDefinition.WriteToXml(writer); writer.WriteStartElement(XmlNamespace.Types, ewsObject.GetXmlElementName()); extendedProperty.WriteToXml(writer, XmlElementNames.ExtendedProperty); writer.WriteEndElement(); writer.WriteEndElement(); } foreach (ExtendedProperty extendedProperty in this.RemovedItems) { writer.WriteStartElement(XmlNamespace.Types, ewsObject.GetDeleteFieldXmlElementName()); extendedProperty.PropertyDefinition.WriteToXml(writer); writer.WriteEndElement(); } return(true); }
/// <summary> /// Writes the update to XML. /// </summary> /// <param name="writer">The writer.</param> /// <param name="ewsObject">The ews object.</param> /// <param name="ownerDictionaryXmlElementName">Name of the owner dictionary XML element.</param> /// <returns>True if update XML was written.</returns> internal override bool WriteSetUpdateToXml( EwsServiceXmlWriter writer, ServiceObject ewsObject, string ownerDictionaryXmlElementName) { List <string> fieldsToSet = new List <string>(); foreach (string xmlElementName in this.propertyBag.AddedItems) { fieldsToSet.Add(xmlElementName); } foreach (string xmlElementName in this.propertyBag.ModifiedItems) { fieldsToSet.Add(xmlElementName); } foreach (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.ToString()); writer.WriteEndElement(); // IndexedFieldURI writer.WriteStartElement(XmlNamespace.Types, ewsObject.GetXmlElementName()); writer.WriteStartElement(XmlNamespace.Types, ownerDictionaryXmlElementName); writer.WriteStartElement(XmlNamespace.Types, XmlElementNames.Entry); this.WriteAttributesToXml(writer); writer.WriteElementValue( XmlNamespace.Types, xmlElementName, this.propertyBag[xmlElementName]); writer.WriteEndElement(); // Entry writer.WriteEndElement(); // ownerDictionaryXmlElementName writer.WriteEndElement(); // ewsObject.GetXmlElementName() writer.WriteEndElement(); // ewsObject.GetSetFieldXmlElementName() } foreach (string xmlElementName in this.propertyBag.RemovedItems) { this.InternalWriteDeleteFieldToXml( writer, ewsObject, xmlElementName); } return(true); }
/// <summary> /// Writes updates to XML. /// </summary> /// <param name="writer">The writer.</param> /// <param name="ewsObject">The ews object.</param> /// <param name="propertyDefinition">Property definition.</param> /// <returns> /// True if property generated serialization. /// </returns> bool ICustomUpdateSerializer.WriteSetUpdateToXml( EwsServiceXmlWriter writer, ServiceObject ewsObject, PropertyDefinition propertyDefinition) { List <TEntry> tempEntries = new List <TEntry>(); foreach (TKey key in this.addedEntries) { tempEntries.Add(this.entries[key]); } foreach (TKey key in this.modifiedEntries) { tempEntries.Add(this.entries[key]); } foreach (TEntry entry in tempEntries) { if (!entry.WriteSetUpdateToXml( writer, ewsObject, propertyDefinition.XmlElementName)) { writer.WriteStartElement(XmlNamespace.Types, ewsObject.GetSetFieldXmlElementName()); this.WriteUriToXml(writer, entry.Key); writer.WriteStartElement(XmlNamespace.Types, ewsObject.GetXmlElementName()); writer.WriteStartElement(XmlNamespace.Types, propertyDefinition.XmlElementName); entry.WriteToXml(writer, this.GetEntryXmlElementName(entry)); writer.WriteEndElement(); writer.WriteEndElement(); writer.WriteEndElement(); } } foreach (TEntry entry in this.removedEntries.Values) { if (!entry.WriteDeleteUpdateToXml(writer, ewsObject)) { writer.WriteStartElement(XmlNamespace.Types, ewsObject.GetDeleteFieldXmlElementName()); this.WriteUriToXml(writer, entry.Key); writer.WriteEndElement(); } } return(true); }
/// <summary> /// Creates the json set update. /// </summary> /// <param name="value">The value.</param> /// <param name="service">The service.</param> /// <param name="serviceObject">The service object.</param> /// <returns></returns> internal static JsonObject CreateJsonSetUpdate(ExtendedProperty value, ExchangeService service, ServiceObject serviceObject) { JsonObject jsonUpdate = new JsonObject(); jsonUpdate.AddTypeParameter(serviceObject.GetSetFieldXmlElementName()); jsonUpdate.Add(JsonNames.Path, (value.PropertyDefinition as IJsonSerializable).ToJson(service)); JsonObject jsonServiceObject = new JsonObject(); jsonServiceObject.AddTypeParameter(serviceObject.GetXmlElementName()); jsonServiceObject.Add(XmlElementNames.ExtendedProperty, new object[] { value.InternalToJson(service) }); jsonUpdate.Add(GetPropertyUpdateItemName(serviceObject), jsonServiceObject); return(jsonUpdate); }
/// <summary> /// Creates the json set update. /// </summary> /// <param name="propertyDefinition">The property definition.</param> /// <param name="service">The service.</param> /// <param name="serviceObject">The service object.</param> /// <param name="propertyBag">The property bag.</param> /// <returns></returns> internal static JsonObject CreateJsonSetUpdate(PropertyDefinition propertyDefinition, ExchangeService service, ServiceObject serviceObject, PropertyBag propertyBag) { JsonObject jsonUpdate = new JsonObject(); jsonUpdate.AddTypeParameter(serviceObject.GetSetFieldXmlElementName()); jsonUpdate.Add(JsonNames.Path, (propertyDefinition as IJsonSerializable).ToJson(service)); JsonObject jsonServiceObject = new JsonObject(); jsonServiceObject.AddTypeParameter(serviceObject.GetXmlElementName()); propertyDefinition.WriteJsonValue(jsonServiceObject, propertyBag, service, true); jsonUpdate.Add(GetPropertyUpdateItemName(serviceObject), jsonServiceObject); return(jsonUpdate); }
/// <summary> /// Writes the set update to json. /// </summary> /// <param name="service">The service.</param> /// <param name="ewsObject">The ews object.</param> /// <param name="propertyDefinition">The property definition.</param> /// <param name="updates">The updates.</param> /// <returns></returns> internal override bool WriteSetUpdateToJson(ExchangeService service, ServiceObject ewsObject, PropertyDefinition propertyDefinition, List <JsonObject> updates) { List <string> propertiesToSet = new List <string>(); propertiesToSet.AddRange(this.propertyBag.AddedItems); propertiesToSet.AddRange(this.propertyBag.ModifiedItems); foreach (string propertyName in propertiesToSet) { JsonObject jsonUpdate = new JsonObject(); jsonUpdate.AddTypeParameter(ewsObject.GetSetFieldXmlElementName()); JsonObject jsonUri = new JsonObject(); jsonUri.AddTypeParameter(JsonNames.PathToIndexedFieldType); jsonUri.Add(XmlAttributeNames.FieldURI, GetFieldUri(propertyName)); jsonUri.Add(XmlAttributeNames.FieldIndex, this.Key.ToString()); jsonUpdate.Add(JsonNames.Path, jsonUri); JsonObject jsonProperty = new JsonObject(); jsonProperty.Add(XmlAttributeNames.Key, this.Key); jsonProperty.Add(propertyName, this.propertyBag[propertyName]); JsonObject jsonServiceObject = new JsonObject(); jsonServiceObject.AddTypeParameter(ewsObject.GetXmlElementName()); jsonServiceObject.Add(propertyDefinition.XmlElementName, new JsonObject[] { jsonProperty }); jsonUpdate.Add(PropertyBag.GetPropertyUpdateItemName(ewsObject), jsonServiceObject); updates.Add(jsonUpdate); } foreach (string propertyName in this.propertyBag.RemovedItems) { this.InternalWriteDeleteUpdateToJson( ewsObject, propertyName, updates); } return(true); }
/// <summary> /// Writes the set update to json. /// </summary> /// <param name="service">The service.</param> /// <param name="ewsObject">The ews object.</param> /// <param name="propertyDefinition">The property definition.</param> /// <param name="updates">The updates.</param> /// <returns></returns> bool ICustomUpdateSerializer.WriteSetUpdateToJson( ExchangeService service, ServiceObject ewsObject, PropertyDefinition propertyDefinition, List <JsonObject> updates) { List <TEntry> tempEntries = new List <TEntry>(); foreach (TKey key in this.addedEntries) { tempEntries.Add(this.entries[key]); } foreach (TKey key in this.modifiedEntries) { tempEntries.Add(this.entries[key]); } foreach (TEntry entry in tempEntries) { if (!entry.WriteSetUpdateToJson( service, ewsObject, propertyDefinition, updates)) { JsonObject jsonUpdate = new JsonObject(); jsonUpdate.AddTypeParameter(ewsObject.GetSetFieldXmlElementName()); JsonObject jsonUri = new JsonObject(); jsonUri.AddTypeParameter(JsonNames.PathToIndexedFieldType); jsonUri.Add(XmlAttributeNames.FieldURI, this.GetFieldURI()); jsonUri.Add(XmlAttributeNames.FieldIndex, entry.Key.ToString()); jsonUpdate.Add(JsonNames.Path, jsonUri); object jsonProperty = entry.InternalToJson(service); JsonObject jsonServiceObject = new JsonObject(); jsonServiceObject.AddTypeParameter(ewsObject.GetXmlElementName()); jsonServiceObject.Add(propertyDefinition.XmlElementName, new object[] { jsonProperty }); jsonUpdate.Add(PropertyBag.GetPropertyUpdateItemName(ewsObject), jsonServiceObject); updates.Add(jsonUpdate); } } foreach (TEntry entry in this.removedEntries.Values) { if (!entry.WriteDeleteUpdateToJson(service, ewsObject, updates)) { JsonObject jsonUpdate = new JsonObject(); jsonUpdate.AddTypeParameter(ewsObject.GetDeleteFieldXmlElementName()); JsonObject jsonUri = new JsonObject(); jsonUri.AddTypeParameter(JsonNames.PathToIndexedFieldType); jsonUri.Add(XmlAttributeNames.FieldURI, this.GetFieldURI()); jsonUri.Add(XmlAttributeNames.FieldIndex, entry.Key.ToString()); jsonUpdate.Add(JsonNames.Path, jsonUri); updates.Add(jsonUpdate); } } return(true); }