Пример #1
0
    /// <summary>
    /// Load from xml.
    /// </summary>
    /// <param name="reader">The reader.</param>
    /// <returns>Retention policy tag object.</returns>
    static RetentionPolicyTag LoadFromXml(EwsServiceXmlReader reader)
    {
        reader.EnsureCurrentNodeIsStartElement(XmlNamespace.Types, XmlElementNames.RetentionPolicyTag);

        RetentionPolicyTag retentionPolicyTag = new RetentionPolicyTag();

        retentionPolicyTag.DisplayName     = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.DisplayName);
        retentionPolicyTag.RetentionId     = new Guid(reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.RetentionId));
        retentionPolicyTag.RetentionPeriod = reader.ReadElementValue <int>(XmlNamespace.Types, XmlElementNames.RetentionPeriod);
        retentionPolicyTag.Type            = reader.ReadElementValue <ElcFolderType>(XmlNamespace.Types, XmlElementNames.Type);
        retentionPolicyTag.RetentionAction = reader.ReadElementValue <RetentionActionType>(XmlNamespace.Types, XmlElementNames.RetentionAction);

        // Description is not a required property.
        reader.Read();
        if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.Description))
        {
            retentionPolicyTag.Description = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.Description);
        }

        retentionPolicyTag.IsVisible = reader.ReadElementValue <bool>(XmlNamespace.Types, XmlElementNames.IsVisible);
        retentionPolicyTag.OptedInto = reader.ReadElementValue <bool>(XmlNamespace.Types, XmlElementNames.OptedInto);
        retentionPolicyTag.IsArchive = reader.ReadElementValue <bool>(XmlNamespace.Types, XmlElementNames.IsArchive);

        return(retentionPolicyTag);
    }
Пример #2
0
    bool TryReadElementFromXml(EwsServiceXmlReader reader)
    {
        reader.EnsureCurrentNodeIsStartElement(this.Namespace, XmlElementNames.DictionaryEntry);

        this.LoadEntry(reader);

        return(true);
    }
Пример #3
0
        /// <summary>
        /// Loads from XML.
        /// </summary>
        /// <param name="reader">The reader.</param>
        internal void LoadFromXml(EwsServiceXmlReader reader)
        {
            reader.EnsureCurrentNodeIsStartElement(XmlNamespace.Types, XmlElementNames.Duration);

            this.startTime = reader.ReadElementValueAsDateTime(XmlNamespace.Types, XmlElementNames.StartTime).Value;
            this.endTime = reader.ReadElementValueAsDateTime(XmlNamespace.Types, XmlElementNames.EndTime).Value;

            reader.ReadEndElement(XmlNamespace.Types, XmlElementNames.Duration);
        }
Пример #4
0
    /// <summary>
    /// Loads from XML.
    /// </summary>
    /// <param name="reader">The reader.</param>
    void LoadFromXml(EwsServiceXmlReader reader)
    {
        reader.EnsureCurrentNodeIsStartElement(XmlNamespace.Types, XmlElementNames.Duration);

        this.startTime = reader.ReadElementValueAsDateTime(XmlNamespace.Types, XmlElementNames.StartTime).Value;
        this.endTime   = reader.ReadElementValueAsDateTime(XmlNamespace.Types, XmlElementNames.EndTime).Value;

        reader.ReadEndElement(XmlNamespace.Types, XmlElementNames.Duration);
    }
Пример #5
0
    /// <summary>
    /// Load from xml
    /// </summary>
    /// <param name="reader"></param>
    /// <returns></returns>
    static MailboxStatisticsItem LoadFromXml(EwsServiceXmlReader reader)
    {
        MailboxStatisticsItem msi = new MailboxStatisticsItem();

        reader.EnsureCurrentNodeIsStartElement(XmlNamespace.Types, XmlElementNames.MailboxStat);
        msi.MailboxId   = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.MailboxId);
        msi.DisplayName = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.DisplayName);
        msi.ItemCount   = reader.ReadElementValue <long>(XmlNamespace.Types, XmlElementNames.ItemCount);
        msi.Size        = reader.ReadElementValue <ulong>(XmlNamespace.Types, XmlElementNames.Size);
        return(msi);
    }
Пример #6
0
    /// <summary>
    /// Load from xml
    /// </summary>
    /// <param name="reader"></param>
    /// <returns></returns>
    static SearchRefinerItem LoadFromXml(EwsServiceXmlReader reader)
    {
        SearchRefinerItem sri = new SearchRefinerItem();

        reader.EnsureCurrentNodeIsStartElement(XmlNamespace.Types, XmlElementNames.Refiner);
        sri.Name  = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.Name);
        sri.Value = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.Value);
        sri.Count = reader.ReadElementValue <long>(XmlNamespace.Types, XmlElementNames.Count);
        sri.Token = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.Token);
        return(sri);
    }
Пример #7
0
    /// <summary>
    /// Loads from XML.
    /// </summary>
    /// <param name="reader">The reader.</param>
    /// <param name="xmlElementName">Name of the XML element.</param>
    void LoadFromXml(EwsServiceXmlReader reader, String xmlElementName)
    {
        reader.EnsureCurrentNodeIsStartElement(XmlNamespace.Types, xmlElementName);

        if (reader.HasAttributes)
        {
            this.culture = reader.ReadAttributeValue("xml:lang");
        }

        this.message = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.Message);

        reader.ReadEndElement(XmlNamespace.Types, xmlElementName);
    }
Пример #8
0
    void LoadFromXml(EwsServiceXmlReader reader, String xmlElementName)
    {
        reader.EnsureCurrentNodeIsStartElement(XmlNamespace.Types, XmlElementNames.UnifiedGroup);
        do
        {
            reader.Read();
            switch (reader.LocalName)
            {
            case XmlElementNames.SmtpAddress:
                this.SmtpAddress = reader.ReadElementValue <String>();
                break;

            case XmlElementNames.LegacyDN:
                this.LegacyDN = reader.ReadElementValue <String>();
                break;

            case XmlElementNames.MailboxGuid:
                this.MailboxGuid = reader.ReadElementValue <String>();
                break;

            case XmlElementNames.DisplayName:
                this.DisplayName = reader.ReadElementValue <String>();
                break;

            case XmlElementNames.IsFavorite:
                this.IsFavorite = reader.ReadElementValue <bool>();
                break;

            case XmlElementNames.LastVisitedTimeUtc:
                this.LastVisitedTimeUtc = reader.ReadElementValue <String>();
                break;

            case XmlElementNames.AccessType:
                this.AccessType = (UnifiedGroupAccessType)Enum.Parse(typeof(UnifiedGroupAccessType), reader.ReadElementValue <String>(), false);
                break;

            case XmlElementNames.ExternalDirectoryObjectId:
                this.ExternalDirectoryObjectId = reader.ReadElementValue <String>();
                break;

            default:
                break;
            }
        }while (!reader.IsEndElement(XmlNamespace.Types, XmlElementNames.UnifiedGroup));

        // Skip end element
        reader.EnsureCurrentNodeIsEndElement(XmlNamespace.NotSpecified, XmlElementNames.UnifiedGroup);
        reader.Read();
    }
        /// <summary>
        /// Loads from XML.
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <returns>SearchFilter.</returns>
        internal static SearchFilter LoadFromXml(EwsServiceXmlReader reader)
        {
            reader.EnsureCurrentNodeIsStartElement();

            string localName = reader.LocalName;

            SearchFilter searchFilter = GetSearchFilterInstance(localName);

            if (searchFilter != null)
            {
                searchFilter.LoadFromXml(reader, reader.LocalName);
            }

            return searchFilter;
        }
Пример #10
0
    /// <summary>
    /// Load extended properties xml
    /// </summary>
    /// <param name="reader">The reader</param>
    /// <returns>Extended properties collection</returns>
    /* private */ static ExtendedPropertyCollection LoadExtendedPropertiesXml(EwsServiceXmlReader reader)
    {
        ExtendedPropertyCollection extendedProperties = new ExtendedPropertyCollection();

        reader.EnsureCurrentNodeIsStartElement(XmlNamespace.Types, XmlElementNames.ExtendedProperties);
        do
        {
            reader.Read();
            if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.ExtendedProperty))
            {
                extendedProperties.LoadFromXml(reader, XmlElementNames.ExtendedProperty);
            }
        }while (!reader.IsEndElement(XmlNamespace.Types, XmlElementNames.ExtendedProperties));

        return(extendedProperties.Count == 0 ? null : extendedProperties);
    }
        /// <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)
        {
            reader.EnsureCurrentNodeIsStartElement();

            TimeZoneTransition transition = TimeZoneTransition.Create(this.timeZoneDefinition, reader.LocalName);

            transition.LoadFromXml(reader);

            EwsUtilities.Assert(
                transition.TargetPeriod != null,
                "TimeZoneTransitionGroup.TryReadElementFromXml",
                "The transition's target period is null.");

            this.transitions.Add(transition);

            return true;
        }
        /// <summary>
        /// Load from xml
        /// </summary>
        /// <param name="reader">The reader</param>
        /// <returns>Searchable mailbox object</returns>
        internal static SearchableMailbox LoadFromXml(EwsServiceXmlReader reader)
        {
            reader.EnsureCurrentNodeIsStartElement(XmlNamespace.Types, XmlElementNames.SearchableMailbox);

            SearchableMailbox searchableMailbox = new SearchableMailbox();
            searchableMailbox.Guid = new Guid(reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.Guid));
            searchableMailbox.SmtpAddress = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.PrimarySmtpAddress);
            bool isExternalMailbox = false;
            bool.TryParse(reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.IsExternalMailbox), out isExternalMailbox);
            searchableMailbox.IsExternalMailbox = isExternalMailbox;
            searchableMailbox.ExternalEmailAddress = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.ExternalEmailAddress);
            searchableMailbox.DisplayName = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.DisplayName);
            bool isMembershipGroup = false;
            bool.TryParse(reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.IsMembershipGroup), out isMembershipGroup);
            searchableMailbox.IsMembershipGroup = isMembershipGroup;
            searchableMailbox.ReferenceId = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.ReferenceId);

            return searchableMailbox;
        }
Пример #13
0
    /// <summary>
    /// Load keyword stats xml
    /// </summary>
    /// <param name="reader">The reader</param>
    /// <returns>Array of keyword statistics</returns>
    /* private */ static KeywordStatisticsSearchResult[] LoadKeywordStatsXml(EwsServiceXmlReader reader)
    {
        List <KeywordStatisticsSearchResult> keywordStats = new List <KeywordStatisticsSearchResult>();

        reader.EnsureCurrentNodeIsStartElement(XmlNamespace.Types, XmlElementNames.KeywordStats);
        do
        {
            reader.Read();
            if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.KeywordStat))
            {
                KeywordStatisticsSearchResult keywordStat = new KeywordStatisticsSearchResult();
                keywordStat.Keyword  = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.Keyword);
                keywordStat.ItemHits = int.Parse(reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.ItemHits));
                keywordStat.Size     = ulong.Parse(reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.Size));
                keywordStats.Add(keywordStat);
            }
        }while (!reader.IsEndElement(XmlNamespace.Types, XmlElementNames.KeywordStats));

        return(keywordStats.Count == 0 ? null : keywordStats.ToArray());
    }
    sealed void LoadPropertyValueFromXml(EwsServiceXmlReader reader, PropertyBag propertyBag)
    {
        ResponseActions value = ResponseActions.None;

        reader.EnsureCurrentNodeIsStartElement(XmlNamespace.Types, this.XmlElementName);

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

                if (reader.IsStartElement())
                {
                    value |= GetResponseAction(reader.LocalName);
                }
            }while (!reader.IsEndElement(XmlNamespace.Types, this.XmlElementName));
        }

        propertyBag[this] = value;
    }
Пример #15
0
    void LoadFromXml(EwsServiceXmlReader reader, String xmlElementName)
    {
        reader.EnsureCurrentNodeIsStartElement(XmlNamespace.Types, XmlElementNames.UnifiedGroupsSet);

        do
        {
            reader.Read();
            switch (reader.LocalName)
            {
            case XmlElementNames.FilterType:
                this.FilterType = (UnifiedGroupsFilterType)Enum.Parse(typeof(UnifiedGroupsFilterType), reader.ReadElementValue(), false);
                break;

            case XmlElementNames.TotalGroups:
                this.TotalGroups = reader.ReadElementValue <int>();
                break;

            case XmlElementNames.GroupsTag:
                reader.Read();
                while (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.UnifiedGroup))
                {
                    UnifiedGroup unifiedGroup = new UnifiedGroup();
                    unifiedGroup.LoadFromXml(reader, XmlElementNames.UnifiedGroup);
                    this.unifiedGroups.Add(unifiedGroup);
                }

                // Skip end element.
                reader.EnsureCurrentNodeIsEndElement(XmlNamespace.NotSpecified, XmlElementNames.GroupsTag);
                reader.Read();
                break;

            default:
                break;
            }
        }while (!reader.IsEndElement(XmlNamespace.Types, XmlElementNames.UnifiedGroupsSet));

        // Skip end element
        reader.EnsureCurrentNodeIsEndElement(XmlNamespace.Types, XmlElementNames.UnifiedGroupsSet);
        reader.Read();
    }
Пример #16
0
    /// <summary>
    /// Load from xml
    /// </summary>
    /// <param name="reader">The reader</param>
    /// <returns>Searchable mailbox object</returns>
    static SearchableMailbox LoadFromXml(EwsServiceXmlReader reader)
    {
        reader.EnsureCurrentNodeIsStartElement(XmlNamespace.Types, XmlElementNames.SearchableMailbox);

        SearchableMailbox searchableMailbox = new SearchableMailbox();

        searchableMailbox.Guid        = new Guid(reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.Guid));
        searchableMailbox.SmtpAddress = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.PrimarySmtpAddress);
        bool isExternalMailbox = false;

        bool.TryParse(reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.IsExternalMailbox), out isExternalMailbox);
        searchableMailbox.IsExternalMailbox    = isExternalMailbox;
        searchableMailbox.ExternalEmailAddress = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.ExternalEmailAddress);
        searchableMailbox.DisplayName          = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.DisplayName);
        bool isMembershipGroup = false;

        bool.TryParse(reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.IsMembershipGroup), out isMembershipGroup);
        searchableMailbox.IsMembershipGroup = isMembershipGroup;
        searchableMailbox.ReferenceId       = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.ReferenceId);

        return(searchableMailbox);
    }
        /// <summary>
        /// Loads from XML.
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <param name="propertyBag">The property bag.</param>
        internal override sealed void LoadPropertyValueFromXml(EwsServiceXmlReader reader, PropertyBag propertyBag)
        {
            ResponseActions value = ResponseActions.None;

            reader.EnsureCurrentNodeIsStartElement(XmlNamespace.Types, this.XmlElementName);

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

                    if (reader.IsStartElement())
                    {
                        value |= GetResponseAction(reader.LocalName);
                    }
                }
                while (!reader.IsEndElement(XmlNamespace.Types, this.XmlElementName));
            }

            propertyBag[this] = value;
        }
         /// <summary>
         /// Read Conversations from XML.
         /// </summary>
         /// <param name="reader">The reader.</param>
         /// <param name="xmlElementName">The name of the xml element</param>
         internal override void LoadFromXml(EwsServiceXmlReader reader, string xmlElementName)
         {
             reader.EnsureCurrentNodeIsStartElement(XmlNamespace.Types, XmlElementNames.UnifiedGroupsSet);

             do
             {
                 reader.Read();
                 switch (reader.LocalName)
                 {
                     case XmlElementNames.FilterType:
                         this.FilterType = (UnifiedGroupsFilterType)Enum.Parse(typeof(UnifiedGroupsFilterType), reader.ReadElementValue(), false);
                         break;
                     case XmlElementNames.TotalGroups:
                         this.TotalGroups = reader.ReadElementValue<int>();
                         break;                     
                     case XmlElementNames.GroupsTag:
                         reader.Read();
                         while (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.UnifiedGroup))
                         {
                             UnifiedGroup unifiedGroup = new UnifiedGroup();
                             unifiedGroup.LoadFromXml(reader, XmlElementNames.UnifiedGroup);
                             this.unifiedGroups.Add(unifiedGroup);
                         }
                         
                         // Skip end element.
                         reader.EnsureCurrentNodeIsEndElement(XmlNamespace.NotSpecified, XmlElementNames.GroupsTag);
                         reader.Read();
                         break;
                     default:
                         break;
                 }
             }
             while (!reader.IsEndElement(XmlNamespace.Types, XmlElementNames.UnifiedGroupsSet));

             // Skip end element
             reader.EnsureCurrentNodeIsEndElement(XmlNamespace.Types, XmlElementNames.UnifiedGroupsSet);
             reader.Read();
         }
Пример #19
0
    /// <summary>
    /// Load failed mailboxes xml
    /// </summary>
    /// <param name="rootXmlNamespace">Root xml namespace</param>
    /// <param name="reader">The reader</param>
    /// <returns>Array of failed mailboxes</returns>
    static FailedSearchMailbox[] LoadFailedMailboxesXml(XmlNamespace rootXmlNamespace, EwsServiceXmlReader reader)
    {
        List <FailedSearchMailbox> failedMailboxes = new List <FailedSearchMailbox>();

        reader.EnsureCurrentNodeIsStartElement(rootXmlNamespace, XmlElementNames.FailedMailboxes);
        do
        {
            reader.Read();
            if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.FailedMailbox))
            {
                String mailbox   = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.Mailbox);
                int    errorCode = 0;
                int.TryParse(reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.ErrorCode), out errorCode);
                String errorMessage = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.ErrorMessage);
                bool   isArchive    = false;
                bool.TryParse(reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.IsArchive), out isArchive);

                failedMailboxes.Add(new FailedSearchMailbox(mailbox, errorCode, errorMessage, isArchive));
            }
        }while (!reader.IsEndElement(rootXmlNamespace, XmlElementNames.FailedMailboxes));

        return(failedMailboxes.Count == 0 ? null : failedMailboxes.ToArray());
    }
        /// <summary>
        /// Loads from XML.
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <param name="propertyBag">The property bag.</param>
        internal override void LoadPropertyValueFromXml(EwsServiceXmlReader reader, PropertyBag propertyBag)
        {
            reader.EnsureCurrentNodeIsStartElement(XmlNamespace.Types, XmlElementNames.Recurrence);

            Recurrence recurrence = null;

            reader.Read(XmlNodeType.Element); // This is the pattern element

            recurrence = GetRecurrenceFromString(reader.LocalName);

            recurrence.LoadFromXml(reader, reader.LocalName);

            reader.Read(XmlNodeType.Element); // This is the range element

            RecurrenceRange range = GetRecurrenceRange(reader.LocalName);

            range.LoadFromXml(reader, reader.LocalName);
            range.SetupRecurrence(recurrence);

            reader.ReadEndElementIfNecessary(XmlNamespace.Types, XmlElementNames.Recurrence);

            propertyBag[this] = recurrence;
        }
        /// <summary>
        /// Load from xml.
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <returns>Retention policy tag object.</returns>
        internal static RetentionPolicyTag LoadFromXml(EwsServiceXmlReader reader)
        {
            reader.EnsureCurrentNodeIsStartElement(XmlNamespace.Types, XmlElementNames.RetentionPolicyTag);

            RetentionPolicyTag retentionPolicyTag = new RetentionPolicyTag();
            retentionPolicyTag.DisplayName = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.DisplayName);
            retentionPolicyTag.RetentionId = new Guid(reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.RetentionId));
            retentionPolicyTag.RetentionPeriod = reader.ReadElementValue<int>(XmlNamespace.Types, XmlElementNames.RetentionPeriod);
            retentionPolicyTag.Type = reader.ReadElementValue<ElcFolderType>(XmlNamespace.Types, XmlElementNames.Type);
            retentionPolicyTag.RetentionAction = reader.ReadElementValue<RetentionActionType>(XmlNamespace.Types, XmlElementNames.RetentionAction);

            // Description is not a required property.
            reader.Read();
            if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.Description))
            {
                retentionPolicyTag.Description = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.Description);
            }

            retentionPolicyTag.IsVisible = reader.ReadElementValue<bool>(XmlNamespace.Types, XmlElementNames.IsVisible);
            retentionPolicyTag.OptedInto = reader.ReadElementValue<bool>(XmlNamespace.Types, XmlElementNames.OptedInto);
            retentionPolicyTag.IsArchive = reader.ReadElementValue<bool>(XmlNamespace.Types, XmlElementNames.IsArchive);

            return retentionPolicyTag;
        }
        /// <summary>
        /// Load from xml
        /// </summary>
        /// <param name="reader">The reader</param>
        /// <returns>Discovery search configuration object</returns>
        internal static DiscoverySearchConfiguration LoadFromXml(EwsServiceXmlReader reader)
        {
            List<SearchableMailbox> mailboxes = new List<SearchableMailbox>();

            reader.EnsureCurrentNodeIsStartElement(XmlNamespace.Types, XmlElementNames.DiscoverySearchConfiguration);

            DiscoverySearchConfiguration configuration = new DiscoverySearchConfiguration();
            configuration.SearchId = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.SearchId);

            // the query could be empty means there won't be Query element, hence needs to read and check
            // if the next element is not Query, then it means already read SearchableMailboxes element
            configuration.SearchQuery = string.Empty;
            configuration.InPlaceHoldIdentity = string.Empty;
            configuration.ManagedByOrganization = string.Empty;
            configuration.Language = string.Empty;

            do
            {
                reader.Read();
                if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.SearchQuery))
                {
                    configuration.SearchQuery = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.SearchQuery);
                    reader.ReadEndElementIfNecessary(XmlNamespace.Types, XmlElementNames.SearchQuery);
                }
                else if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.SearchableMailboxes))
                {
                    // search object without any source mailbox is possible, hence need to check if element is empty
                    if (!reader.IsEmptyElement)
                    {
                        while (!reader.IsEndElement(XmlNamespace.Types, XmlElementNames.SearchableMailboxes))
                        {
                            reader.Read();

                            if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.SearchableMailbox))
                            {
                                mailboxes.Add(SearchableMailbox.LoadFromXml(reader));
                                reader.ReadEndElementIfNecessary(XmlNamespace.Types, XmlElementNames.SearchableMailbox);
                            }
                        }
                    }
                }
                else if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.InPlaceHoldIdentity))
                {
                    configuration.InPlaceHoldIdentity = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.InPlaceHoldIdentity);
                    reader.ReadEndElementIfNecessary(XmlNamespace.Types, XmlElementNames.InPlaceHoldIdentity);
                }
                else if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.ManagedByOrganization))
                {
                    configuration.ManagedByOrganization = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.ManagedByOrganization);
                    reader.ReadEndElementIfNecessary(XmlNamespace.Types, XmlElementNames.ManagedByOrganization);
                }
                else if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.Language))
                {
                    configuration.Language = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.Language);
                    reader.ReadEndElementIfNecessary(XmlNamespace.Types, XmlElementNames.Language);
                }
                else
                {
                    break;
                }
            }
            while (!reader.IsEndElement(XmlNamespace.Types, XmlElementNames.DiscoverySearchConfiguration));

            configuration.SearchableMailboxes = mailboxes.Count == 0 ? null : mailboxes.ToArray();

            return configuration;
        }
        /// <summary>
        /// Load from XML.
        /// </summary>
        /// <param name="reader">The reader.</param>
        internal override void InternalLoadFromXml(EwsServiceXmlReader reader)
        {
            base.InternalLoadFromXml(reader);

            this.folderId = new FolderId();
            this.folderId.LoadFromXml(reader, reader.LocalName);

            reader.Read();

            this.ParentFolderId = new FolderId();
            this.ParentFolderId.LoadFromXml(reader, XmlElementNames.ParentFolderId);

            switch (this.EventType)
            {
                case EventType.Moved:
                case EventType.Copied:
                    reader.Read();

                    this.oldFolderId = new FolderId();
                    this.oldFolderId.LoadFromXml(reader, reader.LocalName);

                    reader.Read();

                    this.OldParentFolderId = new FolderId();
                    this.OldParentFolderId.LoadFromXml(reader, reader.LocalName);
                    break;

                case EventType.Modified:
                    reader.Read();
                    if (reader.IsStartElement())
                    {
                        reader.EnsureCurrentNodeIsStartElement(XmlNamespace.Types, XmlElementNames.UnreadCount);
                        this.unreadCount = int.Parse(reader.ReadValue());
                    }
                    break;

                default:
                    break;
            }
        }
Пример #24
0
        /// <summary>
        /// Load failed mailboxes xml
        /// </summary>
        /// <param name="rootXmlNamespace">Root xml namespace</param>
        /// <param name="reader">The reader</param>
        /// <returns>Array of failed mailboxes</returns>
        internal static FailedSearchMailbox[] LoadFailedMailboxesXml(XmlNamespace rootXmlNamespace, EwsServiceXmlReader reader)
        {
            List<FailedSearchMailbox> failedMailboxes = new List<FailedSearchMailbox>();

            reader.EnsureCurrentNodeIsStartElement(rootXmlNamespace, XmlElementNames.FailedMailboxes);
            do
            {
                reader.Read();
                if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.FailedMailbox))
                {
                    string mailbox = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.Mailbox);
                    int errorCode = 0;
                    int.TryParse(reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.ErrorCode), out errorCode);
                    string errorMessage = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.ErrorMessage);
                    bool isArchive = false;
                    bool.TryParse(reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.IsArchive), out isArchive);

                    failedMailboxes.Add(new FailedSearchMailbox(mailbox, errorCode, errorMessage, isArchive));
                }
            }
            while (!reader.IsEndElement(rootXmlNamespace, XmlElementNames.FailedMailboxes));

            return failedMailboxes.Count == 0 ? null : failedMailboxes.ToArray();
        }
    /// <summary>
    /// Load from xml
    /// </summary>
    /// <param name="reader">The reader</param>
    /// <returns>Discovery search configuration object</returns>
    static DiscoverySearchConfiguration LoadFromXml(EwsServiceXmlReader reader)
    {
        List <SearchableMailbox> mailboxes = new List <SearchableMailbox>();

        reader.EnsureCurrentNodeIsStartElement(XmlNamespace.Types, XmlElementNames.DiscoverySearchConfiguration);

        DiscoverySearchConfiguration configuration = new DiscoverySearchConfiguration();

        configuration.SearchId = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.SearchId);

        // the query could be empty means there won't be Query element, hence needs to read and check
        // if the next element is not Query, then it means already read SearchableMailboxes element
        configuration.SearchQuery           = "";
        configuration.InPlaceHoldIdentity   = "";
        configuration.ManagedByOrganization = "";
        configuration.Language = "";

        do
        {
            reader.Read();
            if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.SearchQuery))
            {
                configuration.SearchQuery = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.SearchQuery);
                reader.ReadEndElementIfNecessary(XmlNamespace.Types, XmlElementNames.SearchQuery);
            }
            else if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.SearchableMailboxes))
            {
                // search object without any source mailbox is possible, hence need to check if element is empty
                if (!reader.IsEmptyElement)
                {
                    while (!reader.IsEndElement(XmlNamespace.Types, XmlElementNames.SearchableMailboxes))
                    {
                        reader.Read();

                        if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.SearchableMailbox))
                        {
                            mailboxes.Add(SearchableMailbox.LoadFromXml(reader));
                            reader.ReadEndElementIfNecessary(XmlNamespace.Types, XmlElementNames.SearchableMailbox);
                        }
                    }
                }
            }
            else if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.InPlaceHoldIdentity))
            {
                configuration.InPlaceHoldIdentity = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.InPlaceHoldIdentity);
                reader.ReadEndElementIfNecessary(XmlNamespace.Types, XmlElementNames.InPlaceHoldIdentity);
            }
            else if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.ManagedByOrganization))
            {
                configuration.ManagedByOrganization = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.ManagedByOrganization);
                reader.ReadEndElementIfNecessary(XmlNamespace.Types, XmlElementNames.ManagedByOrganization);
            }
            else if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.Language))
            {
                configuration.Language = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.Language);
                reader.ReadEndElementIfNecessary(XmlNamespace.Types, XmlElementNames.Language);
            }
            else
            {
                break;
            }
        }while (!reader.IsEndElement(XmlNamespace.Types, XmlElementNames.DiscoverySearchConfiguration));

        configuration.SearchableMailboxes = mailboxes.Count == 0 ? null : mailboxes.ToArray();

        return(configuration);
    }
        /// <summary>
        /// Loads from XML.
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <param name="propertyBag">The property bag.</param>
        internal override sealed void LoadPropertyValueFromXml(EwsServiceXmlReader reader, PropertyBag propertyBag)
        {
            reader.EnsureCurrentNodeIsStartElement(XmlNamespace.Types, this.XmlElementName);

            if (!reader.IsEmptyElement || reader.HasAttributes)
            {
                this.InternalLoadFromXml(reader, propertyBag);
            }

            reader.ReadEndElementIfNecessary(XmlNamespace.Types, this.XmlElementName);
        }
        /// <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)
        {
            reader.EnsureCurrentNodeIsStartElement(this.Namespace, XmlElementNames.DictionaryEntry);

            this.LoadEntry(reader);

            return true;
        }
Пример #28
0
    /// <summary>
    /// Load preview items xml
    /// </summary>
    /// <param name="reader">The reader</param>
    /// <returns>Array of preview items</returns>
    /* private */ static SearchPreviewItem[] LoadPreviewItemsXml(EwsServiceXmlReader reader)
    {
        List <SearchPreviewItem> previewItems = new List <SearchPreviewItem>();

        reader.EnsureCurrentNodeIsStartElement(XmlNamespace.Types, XmlElementNames.Items);
        do
        {
            reader.Read();
            if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.SearchPreviewItem))
            {
                SearchPreviewItem previewItem = new SearchPreviewItem();
                do
                {
                    reader.Read();
                    if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.Id))
                    {
                        previewItem.Id = new ItemId();
                        previewItem.Id.ReadAttributesFromXml(reader);
                    }
                    else if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.ParentId))
                    {
                        previewItem.ParentId = new ItemId();
                        previewItem.ParentId.ReadAttributesFromXml(reader);
                    }
                    else if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.Mailbox))
                    {
                        previewItem.Mailbox                    = new PreviewItemMailbox();
                        previewItem.Mailbox.MailboxId          = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.MailboxId);
                        previewItem.Mailbox.PrimarySmtpAddress = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.PrimarySmtpAddress);
                    }
                    else if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.UniqueHash))
                    {
                        previewItem.UniqueHash = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.UniqueHash);
                    }
                    else if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.SortValue))
                    {
                        previewItem.SortValue = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.SortValue);
                    }
                    else if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.OwaLink))
                    {
                        previewItem.OwaLink = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.OwaLink);
                    }
                    else if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.Sender))
                    {
                        previewItem.Sender = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.Sender);
                    }
                    else if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.ToRecipients))
                    {
                        previewItem.ToRecipients = GetRecipients(reader, XmlElementNames.ToRecipients);
                    }
                    else if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.CcRecipients))
                    {
                        previewItem.CcRecipients = GetRecipients(reader, XmlElementNames.CcRecipients);
                    }
                    else if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.BccRecipients))
                    {
                        previewItem.BccRecipients = GetRecipients(reader, XmlElementNames.BccRecipients);
                    }
                    else if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.CreatedTime))
                    {
                        previewItem.CreatedTime = DateTime.Parse(reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.CreatedTime));
                    }
                    else if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.ReceivedTime))
                    {
                        previewItem.ReceivedTime = DateTime.Parse(reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.ReceivedTime));
                    }
                    else if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.SentTime))
                    {
                        previewItem.SentTime = DateTime.Parse(reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.SentTime));
                    }
                    else if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.Subject))
                    {
                        previewItem.Subject = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.Subject);
                    }
                    else if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.Preview))
                    {
                        previewItem.Preview = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.Preview);
                    }
                    else if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.Size))
                    {
                        previewItem.Size = ulong.Parse(reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.Size));
                    }
                    else if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.Importance))
                    {
                        previewItem.Importance = (Importance)Enum.Parse(typeof(Importance), reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.Importance));
                    }
                    else if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.Read))
                    {
                        previewItem.Read = bool.Parse(reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.Read));
                    }
                    else if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.HasAttachment))
                    {
                        previewItem.HasAttachment = bool.Parse(reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.HasAttachment));
                    }
                    else if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.ExtendedProperties))
                    {
                        previewItem.ExtendedProperties = LoadExtendedPropertiesXml(reader);
                    }
                }while (!reader.IsEndElement(XmlNamespace.Types, XmlElementNames.SearchPreviewItem));

                previewItems.Add(previewItem);
            }
        }while (!reader.IsEndElement(XmlNamespace.Types, XmlElementNames.Items));

        return(previewItems.Count == 0 ? null : previewItems.ToArray());
    }
        /// <summary>
        /// Load keyword stats xml
        /// </summary>
        /// <param name="reader">The reader</param>
        /// <returns>Array of keyword statistics</returns>
        private static KeywordStatisticsSearchResult[] LoadKeywordStatsXml(EwsServiceXmlReader reader)
        {
            List<KeywordStatisticsSearchResult> keywordStats = new List<KeywordStatisticsSearchResult>();

            reader.EnsureCurrentNodeIsStartElement(XmlNamespace.Types, XmlElementNames.KeywordStats);
            do
            {
                reader.Read();
                if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.KeywordStat))
                {
                    KeywordStatisticsSearchResult keywordStat = new KeywordStatisticsSearchResult();
                    keywordStat.Keyword = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.Keyword);
                    keywordStat.ItemHits = int.Parse(reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.ItemHits));
                    keywordStat.Size = ulong.Parse(reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.Size));
                    keywordStats.Add(keywordStat);
                }
            }
            while (!reader.IsEndElement(XmlNamespace.Types, XmlElementNames.KeywordStats));

            return keywordStats.Count == 0 ? null : keywordStats.ToArray();
        }
        /// <summary>
        /// Read Conversations from XML.
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <param name="xmlElementName">The xml element to read.</param>
        internal override void LoadFromXml(EwsServiceXmlReader reader, string xmlElementName)
        {
            reader.EnsureCurrentNodeIsStartElement(XmlNamespace.Types, XmlElementNames.UnifiedGroup);
            do
            {
                reader.Read();
                switch (reader.LocalName)
                {
                    case XmlElementNames.SmtpAddress:
                        this.SmtpAddress = reader.ReadElementValue();
                        break;
                    case XmlElementNames.LegacyDN:
                        this.LegacyDN = reader.ReadElementValue();
                        break;
                    case XmlElementNames.MailboxGuid:
                        this.MailboxGuid = reader.ReadElementValue();
                        break;
                    case XmlElementNames.DisplayName:
                        this.DisplayName = reader.ReadElementValue();
                        break;
                    case XmlElementNames.IsFavorite:
                        this.IsFavorite = reader.ReadElementValue<bool>();
                        break;
                    case XmlElementNames.LastVisitedTimeUtc:
                        this.LastVisitedTimeUtc = reader.ReadElementValue();
                        break;
                    case XmlElementNames.AccessType:
                        this.AccessType = (UnifiedGroupAccessType)Enum.Parse(typeof(UnifiedGroupAccessType), reader.ReadElementValue(), false);
                        break;
                    case XmlElementNames.ExternalDirectoryObjectId:
                        this.ExternalDirectoryObjectId = reader.ReadElementValue();
                        break;
                    default:
                        break;
                }
            }
            while (!reader.IsEndElement(XmlNamespace.Types, XmlElementNames.UnifiedGroup));

            // Skip end element
            reader.EnsureCurrentNodeIsEndElement(XmlNamespace.NotSpecified, XmlElementNames.UnifiedGroup);
            reader.Read(); 
        }
            /// <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)
            {
                bool result = base.TryReadElementFromXml(reader);

                if (!result)
                {
                    if (reader.LocalName == XmlElementNames.FieldURIOrConstant)
                    {
                        reader.Read();
                        reader.EnsureCurrentNodeIsStartElement();

                        if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.Constant))
                        {
                            this.value = reader.ReadAttributeValue(XmlAttributeNames.Value);

                            result = true;
                        }
                        else
                        {
                            result = PropertyDefinitionBase.TryLoadFromXml(reader, ref this.otherPropertyDefinition);
                        }
                    }
                }

                return result;
            }
Пример #32
0
        /// <summary>
        /// Loads 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)
        {
            reader.EnsureCurrentNodeIsStartElement(XmlNamespace.Types, xmlElementName);

            if (reader.HasAttributes)
            {
                this.culture = reader.ReadAttributeValue("xml:lang");
            }

            this.message = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.Message);

            reader.ReadEndElement(XmlNamespace.Types, xmlElementName);
        }
        /// <summary>
        /// Loads from XML.
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <param name="propertyBag">The property bag.</param>
        internal override sealed void LoadPropertyValueFromXml(EwsServiceXmlReader reader, PropertyBag propertyBag)
        {
            EffectiveRights value = EffectiveRights.None;

            reader.EnsureCurrentNodeIsStartElement(XmlNamespace.Types, this.XmlElementName);

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

                    if (reader.IsStartElement())
                    {
                        switch (reader.LocalName)
                        {
                            case XmlElementNames.CreateAssociated:
                                if (reader.ReadElementValue<bool>())
                                {
                                    value |= EffectiveRights.CreateAssociated;
                                }
                                break;
                            case XmlElementNames.CreateContents:
                                if (reader.ReadElementValue<bool>())
                                {
                                    value |= EffectiveRights.CreateContents;
                                }
                                break;
                            case XmlElementNames.CreateHierarchy:
                                if (reader.ReadElementValue<bool>())
                                {
                                    value |= EffectiveRights.CreateHierarchy;
                                }
                                break;
                            case XmlElementNames.Delete:
                                if (reader.ReadElementValue<bool>())
                                {
                                    value |= EffectiveRights.Delete;
                                }
                                break;
                            case XmlElementNames.Modify:
                                if (reader.ReadElementValue<bool>())
                                {
                                    value |= EffectiveRights.Modify;
                                }
                                break;
                            case XmlElementNames.Read:
                                if (reader.ReadElementValue<bool>())
                                {
                                    value |= EffectiveRights.Read;
                                }
                                break;
                            case XmlElementNames.ViewPrivateItems:
                                if (reader.ReadElementValue<bool>())
                                {
                                    value |= EffectiveRights.ViewPrivateItems;
                                }
                                break;
                        }
                    }
                }
                while (!reader.IsEndElement(XmlNamespace.Types, this.XmlElementName));
            }

            propertyBag[this] = value;
        }
 /// <summary>
 /// Load from xml
 /// </summary>
 /// <param name="reader"></param>
 /// <returns></returns>
 internal static MailboxStatisticsItem LoadFromXml(EwsServiceXmlReader reader)
 {
     MailboxStatisticsItem msi = new MailboxStatisticsItem();
     reader.EnsureCurrentNodeIsStartElement(XmlNamespace.Types, XmlElementNames.MailboxStat);
     msi.MailboxId = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.MailboxId);
     msi.DisplayName = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.DisplayName);
     msi.ItemCount = reader.ReadElementValue<long>(XmlNamespace.Types, XmlElementNames.ItemCount);
     msi.Size = reader.ReadElementValue<ulong>(XmlNamespace.Types, XmlElementNames.Size);
     return msi;
 }
 /// <summary>
 /// Load from xml
 /// </summary>
 /// <param name="reader"></param>
 /// <returns></returns>
 internal static SearchRefinerItem LoadFromXml(EwsServiceXmlReader reader)
 {
     SearchRefinerItem sri = new SearchRefinerItem();
     reader.EnsureCurrentNodeIsStartElement(XmlNamespace.Types, XmlElementNames.Refiner);
     sri.Name = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.Name);
     sri.Value = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.Value);
     sri.Count = reader.ReadElementValue<long>(XmlNamespace.Types, XmlElementNames.Count);
     sri.Token = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.Token);
     return sri;
 }
        /// <summary>
        /// Load extended properties xml
        /// </summary>
        /// <param name="reader">The reader</param>
        /// <returns>Extended properties collection</returns>
        private static ExtendedPropertyCollection LoadExtendedPropertiesXml(EwsServiceXmlReader reader)
        {
            ExtendedPropertyCollection extendedProperties = new ExtendedPropertyCollection();

            reader.EnsureCurrentNodeIsStartElement(XmlNamespace.Types, XmlElementNames.ExtendedProperties);
            do
            {
                reader.Read();
                if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.ExtendedProperty))
                {
                    extendedProperties.LoadFromXml(reader, XmlElementNames.ExtendedProperty);
                }
            }
            while (!reader.IsEndElement(XmlNamespace.Types, XmlElementNames.ExtendedProperties));

            return extendedProperties.Count == 0 ? null : extendedProperties;
        }
        /// <summary>
        /// Load preview items xml
        /// </summary>
        /// <param name="reader">The reader</param>
        /// <returns>Array of preview items</returns>
        private static SearchPreviewItem[] LoadPreviewItemsXml(EwsServiceXmlReader reader)
        {
            List<SearchPreviewItem> previewItems = new List<SearchPreviewItem>();

            reader.EnsureCurrentNodeIsStartElement(XmlNamespace.Types, XmlElementNames.Items);
            do
            {
                reader.Read();
                if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.SearchPreviewItem))
                {
                    SearchPreviewItem previewItem = new SearchPreviewItem();
                    do
                    {
                        reader.Read();
                        if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.Id))
                        {
                            previewItem.Id = new ItemId();
                            previewItem.Id.ReadAttributesFromXml(reader);
                        }
                        else if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.ParentId))
                        {
                            previewItem.ParentId = new ItemId();
                            previewItem.ParentId.ReadAttributesFromXml(reader);
                        }
                        else if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.Mailbox))
                        {
                            previewItem.Mailbox = new PreviewItemMailbox();
                            previewItem.Mailbox.MailboxId = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.MailboxId);
                            previewItem.Mailbox.PrimarySmtpAddress = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.PrimarySmtpAddress);
                        }
                        else if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.UniqueHash))
                        {
                            previewItem.UniqueHash = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.UniqueHash);
                        }
                        else if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.SortValue))
                        {
                            previewItem.SortValue = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.SortValue);
                        }
                        else if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.OwaLink))
                        {
                            previewItem.OwaLink = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.OwaLink);
                        }
                        else if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.Sender))
                        {
                            previewItem.Sender = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.Sender);
                        }
                        else if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.ToRecipients))
                        {
                            previewItem.ToRecipients = GetRecipients(reader, XmlElementNames.ToRecipients);
                        }
                        else if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.CcRecipients))
                        {
                            previewItem.CcRecipients = GetRecipients(reader, XmlElementNames.CcRecipients);
                        }
                        else if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.BccRecipients))
                        {
                            previewItem.BccRecipients = GetRecipients(reader, XmlElementNames.BccRecipients);
                        }
                        else if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.CreatedTime))
                        {
                            previewItem.CreatedTime = DateTime.Parse(reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.CreatedTime));
                        }
                        else if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.ReceivedTime))
                        {
                            previewItem.ReceivedTime = DateTime.Parse(reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.ReceivedTime));
                        }
                        else if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.SentTime))
                        {
                            previewItem.SentTime = DateTime.Parse(reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.SentTime));
                        }
                        else if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.Subject))
                        {
                            previewItem.Subject = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.Subject);
                        }
                        else if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.Preview))
                        {
                            previewItem.Preview = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.Preview);
                        }
                        else if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.Size))
                        {
                            previewItem.Size = ulong.Parse(reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.Size));
                        }
                        else if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.Importance))
                        {
                            previewItem.Importance = (Importance)Enum.Parse(typeof(Importance), reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.Importance));
                        }
                        else if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.Read))
                        {
                            previewItem.Read = bool.Parse(reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.Read));
                        }
                        else if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.HasAttachment))
                        {
                            previewItem.HasAttachment = bool.Parse(reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.HasAttachment));
                        }
                        else if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.ExtendedProperties))
                        {
                            previewItem.ExtendedProperties = LoadExtendedPropertiesXml(reader);
                        }
                    }
                    while (!reader.IsEndElement(XmlNamespace.Types, XmlElementNames.SearchPreviewItem));

                    previewItems.Add(previewItem);
                }
            }
            while (!reader.IsEndElement(XmlNamespace.Types, XmlElementNames.Items));

            return previewItems.Count == 0 ? null : previewItems.ToArray();
        }