/// <summary>
        /// Reads response elements from XML.
        /// </summary>
        /// <param name="reader">The reader.</param>
        internal override void ReadElementsFromXml(EwsServiceXmlReader reader)
        {
            this.searchableMailboxes.Clear();

            base.ReadElementsFromXml(reader);

            reader.ReadStartElement(XmlNamespace.Messages, XmlElementNames.SearchableMailboxes);
            if (!reader.IsEmptyElement)
            {
                do
                {
                    reader.Read();
                    if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.SearchableMailbox))
                    {
                        this.searchableMailboxes.Add(SearchableMailbox.LoadFromXml(reader));
                    }
                }while (!reader.IsEndElement(XmlNamespace.Messages, XmlElementNames.SearchableMailboxes));
            }

            reader.Read();
            if (reader.IsStartElement(XmlNamespace.Messages, XmlElementNames.FailedMailboxes))
            {
                this.FailedMailboxes = FailedSearchMailbox.LoadFailedMailboxesXml(XmlNamespace.Messages, reader);
            }
        }
示例#2
0
        /// <summary>
        /// Load from xml
        /// </summary>
        /// <param name="reader">The reader</param>
        /// <returns>Non indexable item details result object</returns>
        internal static NonIndexableItemDetailsResult LoadFromXml(EwsServiceXmlReader reader)
        {
            NonIndexableItemDetailsResult nonIndexableItemDetailsResult = new NonIndexableItemDetailsResult();

            reader.ReadStartElement(XmlNamespace.Messages, XmlElementNames.NonIndexableItemDetailsResult);

            do
            {
                reader.Read();

                if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.Items))
                {
                    List <NonIndexableItem> nonIndexableItems = new List <NonIndexableItem>();
                    if (!reader.IsEmptyElement)
                    {
                        do
                        {
                            reader.Read();
                            NonIndexableItem nonIndexableItem = NonIndexableItem.LoadFromXml(reader);
                            if (nonIndexableItem != null)
                            {
                                nonIndexableItems.Add(nonIndexableItem);
                            }
                        }while (!reader.IsEndElement(XmlNamespace.Types, XmlElementNames.Items));

                        nonIndexableItemDetailsResult.Items = nonIndexableItems.ToArray();
                    }
                }

                if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.FailedMailboxes))
                {
                    nonIndexableItemDetailsResult.FailedMailboxes = FailedSearchMailbox.LoadFailedMailboxesXml(XmlNamespace.Types, reader);
                }
            }while (!reader.IsEndElement(XmlNamespace.Messages, XmlElementNames.NonIndexableItemDetailsResult));

            return(nonIndexableItemDetailsResult);
        }
示例#3
0
        /// <summary>
        /// Load from xml
        /// </summary>
        /// <param name="reader">The reader</param>
        /// <returns>Search result object</returns>
        internal static SearchMailboxesResult LoadFromXml(EwsServiceXmlReader reader)
        {
            SearchMailboxesResult searchResult = new SearchMailboxesResult();

            reader.ReadStartElement(XmlNamespace.Messages, XmlElementNames.SearchMailboxesResult);

            List <MailboxQuery> searchQueries = new List <MailboxQuery>();

            do
            {
                reader.Read();
                if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.SearchQueries))
                {
                    reader.ReadStartElement(XmlNamespace.Types, XmlElementNames.MailboxQuery);
                    string query = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.Query);
                    reader.ReadStartElement(XmlNamespace.Types, XmlElementNames.MailboxSearchScopes);
                    List <MailboxSearchScope> mailboxSearchScopes = new List <MailboxSearchScope>();
                    do
                    {
                        reader.Read();
                        if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.MailboxSearchScope))
                        {
                            string mailbox = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.Mailbox);
                            reader.ReadStartElement(XmlNamespace.Types, XmlElementNames.SearchScope);
                            string searchScope = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.SearchScope);
                            reader.ReadEndElement(XmlNamespace.Types, XmlElementNames.MailboxSearchScope);
                            mailboxSearchScopes.Add(new MailboxSearchScope(mailbox, (MailboxSearchLocation)Enum.Parse(typeof(MailboxSearchLocation), searchScope)));
                        }
                    }while (!reader.IsEndElement(XmlNamespace.Types, XmlElementNames.MailboxSearchScopes));
                    reader.ReadEndElementIfNecessary(XmlNamespace.Types, XmlElementNames.MailboxSearchScopes);
                    searchQueries.Add(new MailboxQuery(query, mailboxSearchScopes.ToArray()));
                }
            }while (!reader.IsEndElement(XmlNamespace.Types, XmlElementNames.SearchQueries));
            reader.ReadEndElementIfNecessary(XmlNamespace.Types, XmlElementNames.SearchQueries);
            searchResult.SearchQueries = searchQueries.ToArray();

            searchResult.ResultType    = (SearchResultType)Enum.Parse(typeof(SearchResultType), reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.ResultType));
            searchResult.ItemCount     = int.Parse(reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.ItemCount));
            searchResult.Size          = ulong.Parse(reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.Size));
            searchResult.PageItemCount = int.Parse(reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.PageItemCount));
            searchResult.PageItemSize  = ulong.Parse(reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.PageItemSize));

            do
            {
                reader.Read();
                if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.KeywordStats))
                {
                    searchResult.KeywordStats = LoadKeywordStatsXml(reader);
                }

                if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.Items))
                {
                    searchResult.PreviewItems = LoadPreviewItemsXml(reader);
                }

                if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.FailedMailboxes))
                {
                    searchResult.FailedMailboxes = FailedSearchMailbox.LoadFailedMailboxesXml(XmlNamespace.Types, reader);
                }

                if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.Refiners))
                {
                    List <SearchRefinerItem> refiners = new List <SearchRefinerItem>();
                    do
                    {
                        reader.Read();
                        if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.Refiner))
                        {
                            refiners.Add(SearchRefinerItem.LoadFromXml(reader));
                        }
                    }while (!reader.IsEndElement(XmlNamespace.Types, XmlElementNames.Refiners));
                    if (refiners.Count > 0)
                    {
                        searchResult.Refiners = refiners.ToArray();
                    }
                }

                if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.MailboxStats))
                {
                    List <MailboxStatisticsItem> mailboxStats = new List <MailboxStatisticsItem>();
                    do
                    {
                        reader.Read();
                        if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.MailboxStat))
                        {
                            mailboxStats.Add(MailboxStatisticsItem.LoadFromXml(reader));
                        }
                    }while (!reader.IsEndElement(XmlNamespace.Types, XmlElementNames.MailboxStats));
                    if (mailboxStats.Count > 0)
                    {
                        searchResult.MailboxStats = mailboxStats.ToArray();
                    }
                }
            }while (!reader.IsEndElement(XmlNamespace.Messages, XmlElementNames.SearchMailboxesResult));

            return(searchResult);
        }