/// <summary>
        /// Writes to XML.
        /// </summary>
        /// <param name="writer">The writer.</param>
        /// <param name="xmlNamespace">The XML namespace.</param>
        /// <param name="xmlElementName">Name of the XML element.</param>
        internal void WriteToXml(
            EwsServiceXmlWriter writer,
            XmlNamespace xmlNamespace,
            string xmlElementName)
        {
            EwsUtilities.Assert(
                writer != null,
                "UserConfiguration.WriteToXml",
                "writer is null");
            EwsUtilities.Assert(
                xmlElementName != null,
                "UserConfiguration.WriteToXml",
                "xmlElementName is null");

            writer.WriteStartElement(xmlNamespace, xmlElementName);

            // Write the UserConfigurationName element
            WriteUserConfigurationNameToXml(
                writer, 
                XmlNamespace.Types, 
                this.name, 
                this.parentFolderId);

            // Write the Dictionary element
            if (this.IsPropertyUpdated(UserConfigurationProperties.Dictionary))
            {
                this.dictionary.WriteToXml(writer, XmlElementNames.Dictionary);
            }

            // Write the XmlData element
            if (this.IsPropertyUpdated(UserConfigurationProperties.XmlData))
            {
                this.WriteXmlDataToXml(writer);
            }

            // Write the BinaryData element
            if (this.IsPropertyUpdated(UserConfigurationProperties.BinaryData))
            {
                this.WriteBinaryDataToXml(writer);
            }

            writer.WriteEndElement();
        }
        /// <summary>
        /// Loads this dictionary from the specified reader.
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <param name="xmlNamespace">The dictionary's XML namespace.</param>
        /// <param name="xmlElementName">Name of the XML element representing the dictionary.</param>
        internal override void LoadFromXml(
            EwsServiceXmlReader reader,
            XmlNamespace xmlNamespace,
            string xmlElementName)
        {
            base.LoadFromXml(
                reader,
                xmlNamespace,
                xmlElementName);

            this.isDirty = false;
        }
 /// <summary>
 /// Writes the element value.
 /// </summary>
 /// <param name="xmlNamespace">The XML namespace.</param>
 /// <param name="localName">The local name of the element.</param>
 /// <param name="value">The value.</param>
 public void WriteElementValue(
     XmlNamespace xmlNamespace,
     string localName,
     object value)
 {
     this.WriteElementValue(xmlNamespace, localName, localName, value);
 }
        /// <summary>
        /// Writes to Xml.
        /// </summary>
        /// <param name="writer">The writer.</param>
        /// <param name="xmlNamespace">The XML namespace.</param>
        /// <param name="name">The user configuration name.</param>
        /// <param name="parentFolderId">The Id of the folder containing the user configuration.</param>
        internal static void WriteUserConfigurationNameToXml(
            EwsServiceXmlWriter writer,
            XmlNamespace xmlNamespace,
            string name,
            FolderId parentFolderId)
        {
            EwsUtilities.Assert(
                writer != null,
                "UserConfiguration.WriteUserConfigurationNameToXml",
                "writer is null");
            EwsUtilities.Assert(
                name != null,
                "UserConfiguration.WriteUserConfigurationNameToXml",
                "name is null");
            EwsUtilities.Assert(
                parentFolderId != null,
                "UserConfiguration.WriteUserConfigurationNameToXml",
                "parentFolderId is null");

            writer.WriteStartElement(xmlNamespace, XmlElementNames.UserConfigurationName);

            writer.WriteAttributeValue(XmlAttributeNames.Name, name);

            parentFolderId.WriteToXml(writer);

            writer.WriteEndElement();
        }
 /// <summary>
 /// Writes the start element.
 /// </summary>
 /// <param name="xmlNamespace">The XML namespace.</param>
 /// <param name="localName">The local name of the element.</param>
 public void WriteStartElement(XmlNamespace xmlNamespace, string localName)
 {
     this.xmlWriter.WriteStartElement(
         EwsUtilities.GetNamespacePrefix(xmlNamespace),
         localName,
         EwsUtilities.GetNamespaceUri(xmlNamespace));
 }
 /// <summary>
 /// Writes the element value.
 /// </summary>
 /// <param name="xmlNamespace">The XML namespace.</param>
 /// <param name="localName">The local name of the element.</param>
 /// <param name="displayName">The name that should appear in the exception message when the value can not be serialized.</param>
 /// <param name="value">The value.</param>
 internal void WriteElementValue(XmlNamespace xmlNamespace, string localName, string displayName, object value)
 {
     string stringValue;
     if (this.TryConvertObjectToString(value, out stringValue))
     {
         //  PS # 205106: The code here used to check IsNullOrEmpty on stringValue instead of just null.
         //  Unfortunately, that meant that if someone really needed to update a string property to be the
         //  value "" (String.Empty), they couldn't do it, because we wouldn't emit the element here, causing
         //  an error on the server because an update is required to have a single sub-element that is the
         //  value to update.  So we need to allow an empty string to create an empty element (like <Value />).
         //  Note that changing this check to just check for null is fine, because the other types that get
         //  converted by TryConvertObjectToString() won't return an empty string if the conversion is
         //  successful (for instance, converting an integer to a string won't return an empty string - it'll
         //  always return the stringized integer).
         if (stringValue != null)
         {
             this.WriteStartElement(xmlNamespace, localName);
             this.WriteValue(stringValue, displayName);
             this.WriteEndElement();
         }
     }
     else
     {
         throw new ServiceXmlSerializationException(
                 string.Format(Strings.ElementValueCannotBeSerialized, value.GetType().Name, localName));
     }
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Append a <see cref="XmlElement"/> to the node.
 /// </summary>
 /// <param name="node"></param>
 /// <param name="localName"></param>
 /// <param name="ns"><see cref="XmlNamespace"/> of this element</param>
 /// <returns></returns>
 static public XmlElement AppendElement(this XmlNode node, string localName, XmlNamespace ns)
 {
     return(node.AppendElement(ns.Prefix, localName, ns.Uri));
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Add a Namespace composed of a prefix and a URI to the node
 /// </summary>
 /// <param name="node"></param>
 /// <param name="ns"><see cref="XmlNamespace"/> to add</param>
 static public void AddNamespace(this XmlElement node, XmlNamespace ns)
 {
     node.AddNamespace(ns.Prefix, ns.Uri);
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Set a attribut with the value and the specified Namespace
 /// </summary>
 /// <param name="node"></param>
 /// <param name="localName"></param>
 /// <param name="ns"><see cref="XmlNamespace"/> of this element</param>
 /// <param name="value"></param>
 static public void SetAttribute(this XmlElement node, string localName, XmlNamespace ns, string value)
 {
     node.SetAttribute(localName, ns.Prefix, ns.Uri, value);
 }
        /// <summary>
        /// Parses the soap:Fault content.
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <param name="soapNamespace">The SOAP namespace to use.</param>
        /// <returns>SOAP fault details.</returns>
        internal static SoapFaultDetails Parse(EwsXmlReader reader, XmlNamespace soapNamespace)
        {
            SoapFaultDetails soapFaultDetails = new SoapFaultDetails();

            do
            {
                reader.Read();
                if (reader.NodeType == XmlNodeType.Element)
                {
                    switch (reader.LocalName)
                    {
                        case XmlElementNames.SOAPFaultCodeElementName:
                            soapFaultDetails.FaultCode = reader.ReadElementValue();
                            break;

                        case XmlElementNames.SOAPFaultStringElementName:
                            soapFaultDetails.FaultString = reader.ReadElementValue();
                            break;

                        case XmlElementNames.SOAPFaultActorElementName:
                            soapFaultDetails.FaultActor = reader.ReadElementValue();
                            break;

                        case XmlElementNames.SOAPDetailElementName:
                            soapFaultDetails.ParseDetailNode(reader);
                            break;

                        default:
                            break;
                    }
                }
            }
            while (!reader.IsEndElement(soapNamespace, XmlElementNames.SOAPFaultElementName));

            return soapFaultDetails;
        }
Ejemplo n.º 11
0
 /// <summary>
 /// Create a basic <see cref="XmlElement"/> with the specified Namespace
 /// </summary>
 static public XmlRacine Create(string name, XmlNamespace ns)
 {
     return(Create(name, ns.Uri));
 }