/// <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);
        }
示例#2
0
        /// <summary>
        /// Creates the json delete update.
        /// </summary>
        /// <param name="propertyDefinition">The property definition.</param>
        /// <param name="service">The service.</param>
        /// <param name="serviceObject">The service object.</param>
        /// <returns></returns>
        internal static JsonObject CreateJsonDeleteUpdate(PropertyDefinitionBase propertyDefinition, ExchangeService service, ServiceObject serviceObject)
        {
            JsonObject jsonUpdate = new JsonObject();

            jsonUpdate.AddTypeParameter(serviceObject.GetDeleteFieldXmlElementName());

            jsonUpdate.Add("PropertyPath", (propertyDefinition as IJsonSerializable).ToJson(service));
            return(jsonUpdate);
        }
        /// <summary>
        /// Writes the deletion update to XML.
        /// </summary>
        /// <param name="writer">The writer.</param>
        /// <param name="ewsObject">The ews object.</param>
        /// <returns>
        /// True if property generated serialization.
        /// </returns>
        bool ICustomUpdateSerializer.WriteDeleteUpdateToXml(EwsServiceXmlWriter writer, ServiceObject ewsObject)
        {
            foreach (ExtendedProperty extendedProperty in this.Items)
            {
                writer.WriteStartElement(XmlNamespace.Types, ewsObject.GetDeleteFieldXmlElementName());
                extendedProperty.PropertyDefinition.WriteToXml(writer);
                writer.WriteEndElement();
            }

            return(true);
        }
示例#4
0
 /// <summary>
 /// Write field deletion to XML.
 /// </summary>
 /// <param name="writer">The writer.</param>
 /// <param name="ewsObject">The ews object.</param>
 /// <param name="fieldXmlElementName">Name of the field XML element.</param>
 private void InternalWriteDeleteFieldToXml(
     EwsServiceXmlWriter writer,
     ServiceObject ewsObject,
     string fieldXmlElementName)
 {
     writer.WriteStartElement(XmlNamespace.Types, ewsObject.GetDeleteFieldXmlElementName());
     writer.WriteStartElement(XmlNamespace.Types, XmlElementNames.IndexedFieldURI);
     writer.WriteAttributeValue(XmlAttributeNames.FieldURI, GetFieldUri(fieldXmlElementName));
     writer.WriteAttributeValue(XmlAttributeNames.FieldIndex, this.Key.ToString());
     writer.WriteEndElement(); // IndexedFieldURI
     writer.WriteEndElement(); // ewsObject.GetDeleteFieldXmlElementName()
 }
示例#5
0
        /// <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);
        }
示例#6
0
        /// <summary>
        /// Internal the write delete update to json.
        /// </summary>
        /// <param name="ewsObject">The ews object.</param>
        /// <param name="propertyName">Name of the property.</param>
        /// <param name="updates">The updates.</param>
        internal void InternalWriteDeleteUpdateToJson(ServiceObject ewsObject, string propertyName, List <JsonObject> updates)
        {
            JsonObject jsonUpdate = new JsonObject();

            jsonUpdate.AddTypeParameter(ewsObject.GetDeleteFieldXmlElementName());

            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);

            updates.Add(jsonUpdate);
        }
示例#7
0
        /// <summary>
        /// Writes the update to Json.
        /// </summary>
        /// <param name="service">The service.</param>
        /// <param name="ewsObject">The ews object.</param>
        /// <param name="propertyDefinition">Property definition.</param>
        /// <param name="updates">The updates.</param>
        /// <returns>
        /// True if property generated serialization.
        /// </returns>
        bool ICustomUpdateSerializer.WriteSetUpdateToJson(ExchangeService service, ServiceObject ewsObject, PropertyDefinition propertyDefinition, List <JsonObject> updates)
        {
            // If the collection is empty, delete the property.
            if (this.Count == 0)
            {
                JsonObject jsonUpdate = new JsonObject();

                jsonUpdate.AddTypeParameter(ewsObject.GetDeleteFieldXmlElementName());
                jsonUpdate.Add(JsonNames.Path, (propertyDefinition as IJsonSerializable).ToJson(service));
                return(true);
            }

            // Otherwise, use the default Json serializer.
            else
            {
                return(false);
            }
        }
示例#8
0
        /// <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)
        {
            // If the collection is empty, delete the property.
            if (this.Count == 0)
            {
                writer.WriteStartElement(XmlNamespace.Types, ewsObject.GetDeleteFieldXmlElementName());
                propertyDefinition.WriteToXml(writer);
                writer.WriteEndElement();
                return(true);
            }

            // Otherwise, use the default XML serializer.
            else
            {
                return(false);
            }
        }
示例#9
0
        /// <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);
        }