/// <summary>
 /// Reads the attributes from XML.
 /// </summary>
 /// <param name="reader">The reader.</param>
 internal override void ReadAttributesFromXml(EwsServiceXmlReader reader)
 {
     this.id = reader.ReadAttributeValue(XmlAttributeNames.Id);
 }
Пример #2
0
        /// <summary>
        /// Loads response from XML.
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <param name="xmlElementName">Name of the XML element.</param>
        internal void LoadFromXml(EwsServiceXmlReader reader, string xmlElementName)
        {
            if (!reader.IsStartElement(XmlNamespace.Messages, xmlElementName))
            {
                reader.ReadStartElement(XmlNamespace.Messages, xmlElementName);
            }

            this.result = reader.ReadAttributeValue <ServiceResult>(XmlAttributeNames.ResponseClass);

            if (this.result == ServiceResult.Success || this.result == ServiceResult.Warning)
            {
                if (this.result == ServiceResult.Warning)
                {
                    this.errorMessage = reader.ReadElementValue(XmlNamespace.Messages, XmlElementNames.MessageText);
                }

                this.errorCode = reader.ReadElementValue <ServiceError>(XmlNamespace.Messages, XmlElementNames.ResponseCode);

                if (this.result == ServiceResult.Warning)
                {
                    reader.ReadElementValue <int>(XmlNamespace.Messages, XmlElementNames.DescriptiveLinkKey);
                }

                // If batch processing stopped, EWS returns an empty element. Skip over it.
                if (this.BatchProcessingStopped)
                {
                    do
                    {
                        reader.Read();
                    }while (!reader.IsEndElement(XmlNamespace.Messages, xmlElementName));
                }
                else
                {
                    this.ReadElementsFromXml(reader);

                    reader.ReadEndElementIfNecessary(XmlNamespace.Messages, xmlElementName);
                }
            }
            else
            {
                this.errorMessage = reader.ReadElementValue(XmlNamespace.Messages, XmlElementNames.MessageText);
                this.errorCode    = reader.ReadElementValue <ServiceError>(XmlNamespace.Messages, XmlElementNames.ResponseCode);
                reader.ReadElementValue <int>(XmlNamespace.Messages, XmlElementNames.DescriptiveLinkKey);

                while (!reader.IsEndElement(XmlNamespace.Messages, xmlElementName))
                {
                    reader.Read();

                    if (reader.IsStartElement())
                    {
                        if (!this.LoadExtraErrorDetailsFromXml(reader, reader.LocalName))
                        {
                            reader.SkipCurrentElement();
                        }
                    }
                }
            }

            this.MapErrorCodeToErrorMessage();

            this.Loaded();
        }
Пример #3
0
        /// <summary>
        /// Tries to read element from XML.
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <returns>True if element was read.</returns>
        internal override bool TryReadElementFromXml(EwsServiceXmlReader reader)
        {
            do
            {
                reader.Read();
                InsightValue item = null;

                if (reader.NodeType == XmlNodeType.Element && reader.LocalName == XmlElementNames.Item)
                {
                    switch (reader.ReadAttributeValue("xsi:type"))
                    {
                    case XmlElementNames.StringInsightValue:
                        item = new StringInsightValue();
                        item.LoadFromXml(reader, reader.LocalName);
                        this.ItemList.InternalAdd(item);
                        break;

                    case XmlElementNames.ProfileInsightValue:
                        item = new ProfileInsightValue();
                        item.LoadFromXml(reader, reader.LocalName);
                        this.ItemList.InternalAdd(item);
                        break;

                    case XmlElementNames.JobInsightValue:
                        item = new JobInsightValue();
                        item.LoadFromXml(reader, reader.LocalName);
                        this.ItemList.InternalAdd(item);
                        break;

                    case XmlElementNames.UserProfilePicture:
                        item = new UserProfilePicture();
                        item.LoadFromXml(reader, reader.LocalName);
                        this.ItemList.InternalAdd(item);
                        break;

                    case XmlElementNames.EducationInsightValue:
                        item = new EducationInsightValue();
                        item.LoadFromXml(reader, reader.LocalName);
                        this.ItemList.InternalAdd(item);
                        break;

                    case XmlElementNames.SkillInsightValue:
                        item = new SkillInsightValue();
                        item.LoadFromXml(reader, reader.LocalName);
                        this.ItemList.InternalAdd(item);
                        break;

                    case XmlElementNames.ComputedInsightValue:
                        item = new ComputedInsightValue();
                        item.LoadFromXml(reader, reader.LocalName);
                        this.ItemList.InternalAdd(item);
                        break;

                    case XmlElementNames.MeetingInsightValue:
                        item = new MeetingInsightValue();
                        item.LoadFromXml(reader, reader.LocalName);
                        this.ItemList.InternalAdd(item);
                        break;

                    case XmlElementNames.EmailInsightValue:
                        item = new EmailInsightValue();
                        item.LoadFromXml(reader, reader.LocalName);
                        this.ItemList.InternalAdd(item);
                        break;

                    case XmlElementNames.DelveDocument:
                        item = new DelveDocument();
                        item.LoadFromXml(reader, reader.LocalName);
                        this.ItemList.InternalAdd(item);
                        break;

                    default:
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            } while (!reader.IsEndElement(XmlNamespace.Messages, XmlElementNames.ItemList));

            return(true);
        }
Пример #4
0
 /// <summary>
 /// Reads attributes from XML.
 /// </summary>
 /// <param name="reader">The reader.</param>
 internal override void ReadAttributesFromXml(EwsServiceXmlReader reader)
 {
     this.uniqueId  = reader.ReadAttributeValue(XmlAttributeNames.Id);
     this.changeKey = reader.ReadAttributeValue(XmlAttributeNames.ChangeKey);
 }
 /// <summary>
 /// Reads the attributes from XML.
 /// </summary>
 /// <param name="reader">The reader.</param>
 internal override void ReadAttributesFromXml(EwsServiceXmlReader reader)
 {
     this.name = reader.ReadAttributeValue(XmlAttributeNames.TimeZoneName);
 }
Пример #6
0
        /// <summary>
        /// Loads the attributes from XML.
        /// </summary>
        /// <param name="reader">The reader.</param>
        internal override void LoadAttributesFromXml(EwsServiceXmlReader reader)
        {
            base.LoadAttributesFromXml(reader);

            this.itemId = reader.ReadAttributeValue(XmlAttributeNames.ItemId);
        }
Пример #7
0
 /// <summary>
 /// Reads attributes from XML.
 /// </summary>
 /// <param name="reader">The reader.</param>
 internal override void ReadAttributesFromXml(EwsServiceXmlReader reader)
 {
     this.isExplicit = reader.ReadAttributeValue <bool>(XmlAttributeNames.IsExplicit);
 }
Пример #8
0
        /// <summary>
        /// Reads attributes from XML.
        /// </summary>
        /// <param name="reader">The reader.</param>
        internal override void ReadAttributesFromXml(EwsServiceXmlReader reader)
        {
            string value = reader.ReadAttributeValue(XmlAttributeNames.ClientExtensionType);

            if (!string.IsNullOrEmpty(value))
            {
                this.Type = reader.ReadAttributeValue <ExtensionType>(XmlAttributeNames.ClientExtensionType);
            }

            value = reader.ReadAttributeValue(XmlAttributeNames.ClientExtensionScope);
            if (!string.IsNullOrEmpty(value))
            {
                this.Scope = reader.ReadAttributeValue <ExtensionInstallScope>(XmlAttributeNames.ClientExtensionScope);
            }

            value = reader.ReadAttributeValue(XmlAttributeNames.ClientExtensionMarketplaceAssetID);
            if (!string.IsNullOrEmpty(value))
            {
                this.MarketplaceAssetID = reader.ReadAttributeValue <string>(XmlAttributeNames.ClientExtensionMarketplaceAssetID);
            }

            value = reader.ReadAttributeValue(XmlAttributeNames.ClientExtensionMarketplaceContentMarket);
            if (!string.IsNullOrEmpty(value))
            {
                this.MarketplaceContentMarket = reader.ReadAttributeValue <string>(XmlAttributeNames.ClientExtensionMarketplaceContentMarket);
            }

            value = reader.ReadAttributeValue(XmlAttributeNames.ClientExtensionAppStatus);
            if (!string.IsNullOrEmpty(value))
            {
                this.AppStatus = reader.ReadAttributeValue <string>(XmlAttributeNames.ClientExtensionAppStatus);
            }

            value = reader.ReadAttributeValue(XmlAttributeNames.ClientExtensionEtoken);
            if (!string.IsNullOrEmpty(value))
            {
                this.Etoken = reader.ReadAttributeValue <string>(XmlAttributeNames.ClientExtensionEtoken);
            }

            value = reader.ReadAttributeValue(XmlAttributeNames.ClientExtensionIsAvailable);
            if (!string.IsNullOrEmpty(value))
            {
                this.IsAvailable = reader.ReadAttributeValue <bool>(XmlAttributeNames.ClientExtensionIsAvailable);
            }

            value = reader.ReadAttributeValue(XmlAttributeNames.ClientExtensionIsMandatory);
            if (!string.IsNullOrEmpty(value))
            {
                this.IsMandatory = reader.ReadAttributeValue <bool>(XmlAttributeNames.ClientExtensionIsMandatory);
            }

            value = reader.ReadAttributeValue(XmlAttributeNames.ClientExtensionIsEnabledByDefault);
            if (!string.IsNullOrEmpty(value))
            {
                this.IsEnabledByDefault = reader.ReadAttributeValue <bool>(XmlAttributeNames.ClientExtensionIsEnabledByDefault);
            }

            value = reader.ReadAttributeValue(XmlAttributeNames.ClientExtensionProvidedTo);
            if (!string.IsNullOrEmpty(value))
            {
                this.ProvidedTo = reader.ReadAttributeValue <ClientExtensionProvidedTo>(XmlAttributeNames.ClientExtensionProvidedTo);
            }
        }
 /// <summary>
 /// Reads the attributes from XML.
 /// </summary>
 /// <param name="reader">The reader.</param>
 internal override void ReadAttributesFromXml(EwsServiceXmlReader reader)
 {
     this.id   = reader.ReadAttributeValue(XmlAttributeNames.Id);
     this.name = reader.ReadAttributeValue(XmlAttributeNames.Name);
     this.bias = EwsUtilities.XSDurationToTimeSpan(reader.ReadAttributeValue(XmlAttributeNames.Bias));
 }
Пример #10
0
        /// <summary>
        /// Reads response elements from XML.
        /// </summary>
        /// <param name="reader">The reader.</param>
        internal override void ReadElementsFromXml(EwsServiceXmlReader reader)
        {
            reader.ReadStartElement(XmlNamespace.Messages, XmlElementNames.RootFolder);

            int  totalItemsInView   = reader.ReadAttributeValue <int>(XmlAttributeNames.TotalItemsInView);
            bool moreItemsAvailable = !reader.ReadAttributeValue <bool>(XmlAttributeNames.IncludesLastItemInRange);

            // Ignore IndexedPagingOffset attribute if moreItemsAvailable is false.
            int?nextPageOffset = moreItemsAvailable ? reader.ReadNullableAttributeValue <int>(XmlAttributeNames.IndexedPagingOffset) : null;

            if (!this.isGrouped)
            {
                this.results                = new FindItemsResults <TItem>();
                this.results.TotalCount     = totalItemsInView;
                this.results.NextPageOffset = nextPageOffset;
                this.results.MoreAvailable  = moreItemsAvailable;
                InternalReadItemsFromXml(
                    reader,
                    this.propertySet,
                    this.results.Items);
            }
            else
            {
                this.groupedFindResults                = new GroupedFindItemsResults <TItem>();
                this.groupedFindResults.TotalCount     = totalItemsInView;
                this.groupedFindResults.NextPageOffset = nextPageOffset;
                this.groupedFindResults.MoreAvailable  = moreItemsAvailable;

                reader.ReadStartElement(XmlNamespace.Types, XmlElementNames.Groups);

                if (!reader.IsEmptyElement)
                {
                    do
                    {
                        reader.Read();

                        if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.GroupedItems))
                        {
                            string groupIndex = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.GroupIndex);

                            List <TItem> itemList = new List <TItem>();
                            InternalReadItemsFromXml(
                                reader,
                                this.propertySet,
                                itemList);

                            reader.ReadEndElement(XmlNamespace.Types, XmlElementNames.GroupedItems);

                            this.groupedFindResults.ItemGroups.Add(new ItemGroup <TItem>(groupIndex, itemList));
                        }
                    }while (!reader.IsEndElement(XmlNamespace.Types, XmlElementNames.Groups));
                }
            }

            reader.ReadEndElement(XmlNamespace.Messages, XmlElementNames.RootFolder);

            reader.Read();

            if (reader.IsStartElement(XmlNamespace.Messages, XmlElementNames.HighlightTerms) &&
                !reader.IsEmptyElement)
            {
                do
                {
                    reader.Read();

                    if (reader.NodeType == XmlNodeType.Element)
                    {
                        HighlightTerm term = new HighlightTerm();

                        term.LoadFromXml(
                            reader,
                            XmlNamespace.Types,
                            XmlElementNames.HighlightTerm);
                        this.results.HighlightTerms.Add(term);
                    }
                }while (!reader.IsEndElement(XmlNamespace.Messages, XmlElementNames.HighlightTerms));
            }
        }
 /// <summary>
 /// Reads the attributes from XML.
 /// </summary>
 /// <param name="reader">The reader.</param>
 internal override void ReadAttributesFromXml(EwsServiceXmlReader reader)
 {
     this.key = reader.ReadAttributeValue <TKey>(XmlAttributeNames.Key);
 }
Пример #12
0
 /// <summary>
 /// Reads attributes from XML.
 /// This should always be UTF-8 for MimeContentUTF8
 /// </summary>
 /// <param name="reader">The reader.</param>
 internal override void ReadAttributesFromXml(EwsServiceXmlReader reader)
 {
     this.characterSet = reader.ReadAttributeValue <string>(XmlAttributeNames.CharacterSet);
 }