void ReadElementsFromXml(EwsServiceXmlReader reader)
    {
        if (this.ErrorCode == ServiceError.NoError)
        {
            this.delegateUserResponses = new Collection <DelegateUserResponse>();

            reader.Read();

            if (reader.IsStartElement(XmlNamespace.Messages, XmlElementNames.ResponseMessages))
            {
                int delegateUserIndex = 0;
                do
                {
                    reader.Read();

                    if (reader.IsStartElement(XmlNamespace.Messages, XmlElementNames.DelegateUserResponseMessageType))
                    {
                        DelegateUser delegateUser = null;
                        if (this.readDelegateUsers && (this.delegateUsers != null))
                        {
                            delegateUser = this.delegateUsers[delegateUserIndex];
                        }

                        DelegateUserResponse delegateUserResponse = new DelegateUserResponse(readDelegateUsers, delegateUser);

                        delegateUserResponse.LoadFromXml(reader, XmlElementNames.DelegateUserResponseMessageType);

                        this.delegateUserResponses.Add(delegateUserResponse);

                        delegateUserIndex++;
                    }
                }while (!reader.IsEndElement(XmlNamespace.Messages, XmlElementNames.ResponseMessages));
            }
        }
    }
Beispiel #2
0
    /// <summary>
    /// Load from xml
    /// </summary>
    /// <param name="reader">The reader</param>
    /// <returns>List of non indexable item statistic object</returns>
    static List <NonIndexableItemStatistic> LoadFromXml(EwsServiceXmlReader reader)
    {
        List <NonIndexableItemStatistic> results = new List <NonIndexableItemStatistic>();

        reader.Read();
        if (reader.IsStartElement(XmlNamespace.Messages, XmlElementNames.NonIndexableItemStatistics))
        {
            do
            {
                reader.Read();
                if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.NonIndexableItemStatistic))
                {
                    String mailbox      = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.Mailbox);
                    int    itemCount    = reader.ReadElementValue <int>(XmlNamespace.Types, XmlElementNames.ItemCount);
                    String errorMessage = null;
                    if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.ErrorMessage))
                    {
                        errorMessage = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.ErrorMessage);
                    }

                    results.Add(new NonIndexableItemStatistic {
                        Mailbox = mailbox, ItemCount = itemCount, ErrorMessage = errorMessage
                    });
                }
            }while (!reader.IsEndElement(XmlNamespace.Messages, XmlElementNames.NonIndexableItemStatistics));
        }

        return(results);
    }
        /// <summary>
        /// Load from xml
        /// </summary>
        /// <param name="reader">The reader</param>
        /// <returns>List of non indexable item statistic object</returns>
        internal static List<NonIndexableItemStatistic> LoadFromXml(EwsServiceXmlReader reader)
        {
            List<NonIndexableItemStatistic> results = new List<NonIndexableItemStatistic>();

            reader.Read();
            if (reader.IsStartElement(XmlNamespace.Messages, XmlElementNames.NonIndexableItemStatistics))
            {
                do
                {
                    reader.Read();
                    if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.NonIndexableItemStatistic))
                    {
                        string mailbox = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.Mailbox);
                        int itemCount = reader.ReadElementValue<int>(XmlNamespace.Types, XmlElementNames.ItemCount);
                        string errorMessage = null;
                        if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.ErrorMessage))
                        {
                            errorMessage = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.ErrorMessage);
                        }

                        results.Add(new NonIndexableItemStatistic { Mailbox = mailbox, ItemCount = itemCount, ErrorMessage = errorMessage });
                    }
                }
                while (!reader.IsEndElement(XmlNamespace.Messages, XmlElementNames.NonIndexableItemStatistics));
            }

            return results;
        }
        /// <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);
            }
        }
Beispiel #5
0
    void ReadElementsFromXml(EwsServiceXmlReader reader)
    {
        this.ClientExtensions.Clear();
        base.ReadElementsFromXml(reader);

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

        if (!reader.IsEmptyElement)
        {
            // Because we don't have an element for count of returned object,
            // we have to test the element to determine if it is StartElement of return object or EndElement
            reader.Read();

            while (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.ClientExtension))
            {
                ClientExtension clientExtension = new ClientExtension();
                clientExtension.LoadFromXml(reader, XmlNamespace.Types, XmlElementNames.ClientExtension);
                this.ClientExtensions.Add(clientExtension);

                reader.EnsureCurrentNodeIsEndElement(XmlNamespace.Types, XmlElementNames.ClientExtension);
                reader.Read();
            }

            reader.EnsureCurrentNodeIsEndElement(XmlNamespace.Messages, XmlElementNames.ClientExtensions);
        }

        reader.Read();
        if (reader.IsStartElement(XmlNamespace.Messages, XmlElementNames.ClientExtensionRawMasterTableXml))
        {
            this.rawMasterTableXml = reader.ReadElementValue();
        }
    }
Beispiel #6
0
    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);
        }
    }
        /// <summary>
        /// Loads the free busy view from XML.
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <param name="viewType">Type of free/busy view.</param>
        internal void LoadFreeBusyViewFromXml(EwsServiceXmlReader reader, FreeBusyViewType viewType)
        {
            reader.ReadStartElement(XmlNamespace.Messages, XmlElementNames.FreeBusyView);

            string viewTypeString = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.FreeBusyViewType);

            this.viewType = (FreeBusyViewType)Enum.Parse(typeof(FreeBusyViewType), viewTypeString, false);

            do
            {
                reader.Read();

                if (reader.IsStartElement())
                {
                    switch (reader.LocalName)
                    {
                        case XmlElementNames.MergedFreeBusy:
                            string mergedFreeBusy = reader.ReadElementValue();

                            for (int i = 0; i < mergedFreeBusy.Length; i++)
                            {
                                this.mergedFreeBusyStatus.Add((LegacyFreeBusyStatus)Byte.Parse(mergedFreeBusy[i].ToString()));
                            }

                            break;
                        case XmlElementNames.CalendarEventArray:
                            do
                            {
                                reader.Read();

                                if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.CalendarEvent))
                                {
                                    CalendarEvent calendarEvent = new CalendarEvent();

                                    calendarEvent.LoadFromXml(reader, XmlElementNames.CalendarEvent);

                                    this.calendarEvents.Add(calendarEvent);
                                }
                            }
                            while (!reader.IsEndElement(XmlNamespace.Types, XmlElementNames.CalendarEventArray));

                            break;
                        case XmlElementNames.WorkingHours:
                            this.workingHours = new WorkingHours();
                            this.workingHours.LoadFromXml(reader, reader.LocalName);

                            break;
                    }
                }
            }
            while (!reader.IsEndElement(XmlNamespace.Messages, XmlElementNames.FreeBusyView));
        }
Beispiel #8
0
    bool TryReadElementFromXml(EwsServiceXmlReader reader)
    {
        switch (reader.LocalName)
        {
        case XmlElementNames.UserOptions:
            if (!reader.IsEmptyElement)
            {
                do
                {
                    reader.Read();

                    if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.VotingOptionData))
                    {
                        VotingOptionData option = new VotingOptionData();
                        option.LoadFromXml(reader, reader.LocalName);
                        this.userOptions.Add(option);
                    }
                }while (!reader.IsEndElement(XmlNamespace.Types, XmlElementNames.UserOptions));
            }
            return(true);

        case XmlElementNames.VotingResponse:
            this.votingResponse = reader.ReadElementValue <string>();
            return(true);

        default:
            return(false);
        }
    }
Beispiel #9
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);
    }
Beispiel #10
0
    void ReadElementsFromXml(EwsServiceXmlReader reader)
    {
        this.Rooms.Clear();
        base.ReadElementsFromXml(reader);

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

        if (!reader.IsEmptyElement)
        {
            // Because we don't have an element for count of returned object,
            // we have to test the element to determine if it is StartElement of return object or EndElement
            reader.Read();
            while (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.Room))
            {
                reader.Read();     // skip the start <Room>

                EmailAddress emailAddress = new EmailAddress();
                emailAddress.LoadFromXml(reader, XmlElementNames.RoomId);
                this.Rooms.Add(emailAddress);

                reader.ReadEndElement(XmlNamespace.Types, XmlElementNames.Room);
                reader.Read();
            }

            reader.EnsureCurrentNodeIsEndElement(XmlNamespace.Messages, XmlElementNames.Rooms);
        }
    }
Beispiel #11
0
    /// <summary>
    /// Read the response from Exchange 2013.
    /// This method assumes that the reader is currently at the Manifests element.
    /// </summary>
    /// <param name="reader">The reader.</param>
    /* private */ void ReadFromExchange2013Sp1(EwsServiceXmlReader reader)
    {
        ////<GetAppManifestsResponse ResponseClass="Success" xmlns="http://schemas.microsoft.com/exchange/services/2006/messages">
        ////  <ResponseCode>NoError</ResponseCode>
        ////  <m:Apps xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages">
        ////    <t:App xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">       <--- reader should be at this node at the beginning of the loop
        ////      <t:Metadata>
        ////        <t:EndNodeUrl>http://o15.officeredir.microsoft.com/r/rlidMktplcExchRedirect?app=outlook.exe&amp;ver=15&amp;clid=1033&amp;p1=15d0d766d0&amp;p2=4&amp;p3=0&amp;p4=WA&amp;p5=en-US\WA102996382&amp;Scope=2&amp;CallBackURL=https%3a%2f%2fexhv-4880%2fecp%2fExtension%2finstallFromURL.slab%3fexsvurl%3d1&amp;DeployId=EXHV-4680dom.extest.microsoft.com</t:EndNodeUrl>
        ////        <t:AppStatus>2.3</t:AppStatus>
        ////        <t:ActionUrl>http://o15.officeredir.microsoft.com/r/rlidMktplcExchRedirect?app=outlook.exe&amp;ver=15&amp;clid=1033&amp;p1=15d0d766d0&amp;p2=4&amp;p3=0&amp;p4=WA&amp;p5=en-US\WA102996382&amp;Scope=2&amp;CallBackURL=https%3a%2f%2fexhv-4880%2fecp%2fExtension%2finstallFromURL.slab%3fexsvurl%3d1&amp;DeployId=EXHV-4680dom.extest.microsoft.com</t:ActionUrl>
        ////      </t:Metadata>
        ////      <t:Manifest>[base 64 encoded manifest]</t:Manifest>
        ////    </t:App>
        ////    <t:App xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
        ////      ....
        ////  <m:Apps>    <----- reader should be at this node at the end of the loop
        while (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.App))
        {
            ClientApp clientApp = new ClientApp();
            clientApp.LoadFromXml(reader, XmlElementNames.App);

            this.Apps.Add(clientApp);
            this.Manifests.Add(clientApp.Manifest);

            reader.EnsureCurrentNodeIsEndElement(XmlNamespace.Types, XmlElementNames.App);
            reader.Read();
        }
    }
        /// <summary>
        /// Reads response elements from XML.
        /// </summary>
        /// <param name="reader">The reader.</param>
        internal override void ReadElementsFromXml(EwsServiceXmlReader reader)
        {
            this.ClientExtensions.Clear();
            base.ReadElementsFromXml(reader);
            
            reader.ReadStartElement(XmlNamespace.Messages, XmlElementNames.ClientExtensions);

            if (!reader.IsEmptyElement)
            {
                // Because we don't have an element for count of returned object,
                // we have to test the element to determine if it is StartElement of return object or EndElement
                reader.Read();

                while (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.ClientExtension))
                {
                    ClientExtension clientExtension = new ClientExtension();
                    clientExtension.LoadFromXml(reader, XmlNamespace.Types, XmlElementNames.ClientExtension);
                    this.ClientExtensions.Add(clientExtension);

                    reader.EnsureCurrentNodeIsEndElement(XmlNamespace.Types, XmlElementNames.ClientExtension);
                    reader.Read();
                }

                reader.EnsureCurrentNodeIsEndElement(XmlNamespace.Messages, XmlElementNames.ClientExtensions);
            }

            reader.Read();
            if (reader.IsStartElement(XmlNamespace.Messages, XmlElementNames.ClientExtensionRawMasterTableXml))
            {
                this.rawMasterTableXml = reader.ReadElementValue();
            }
        }
        /// <summary>
        /// Loads from XML.
        /// </summary>
        /// <param name="reader">The reader.</param>
        internal void LoadFromXml(EwsServiceXmlReader reader)
        {
            reader.ReadStartElement(XmlNamespace.Types, XmlElementNames.Resolution);

            reader.ReadStartElement(XmlNamespace.Types, XmlElementNames.Mailbox);
            this.mailbox.LoadFromXml(reader, XmlElementNames.Mailbox);

            reader.Read();
            if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.Contact))
            {
                this.contact = new Contact(this.owner.Session);

                // Contacts returned by ResolveNames should behave like Contact.Load with FirstClassPropertySet specified.
                this.contact.LoadFromXml(
                                    reader,
                                    true,                               /* clearPropertyBag */
                                    PropertySet.FirstClassProperties,
                                    false);                             /* summaryPropertiesOnly */

                reader.ReadEndElement(XmlNamespace.Types, XmlElementNames.Resolution);
            }
            else
            {
                reader.EnsureCurrentNodeIsEndElement(XmlNamespace.Types, XmlElementNames.Resolution);
            }
        }
        /// <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)
        {
            switch (reader.LocalName)
            {
                case XmlElementNames.UserOptions:
                    if (!reader.IsEmptyElement)
                    {
                        do
                        {
                            reader.Read();

                            if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.VotingOptionData))
                            {
                                VotingOptionData option = new VotingOptionData();
                                option.LoadFromXml(reader, reader.LocalName);
                                this.userOptions.Add(option);
                            }
                        }
                        while (!reader.IsEndElement(XmlNamespace.Types, XmlElementNames.UserOptions));
                    }
                    return true;
                case XmlElementNames.VotingResponse:
                    this.votingResponse = reader.ReadElementValue<string>();
                    return true;
                default:
                    return false;
            }
        }
        /// <summary>
        /// Reads response elements from XML.
        /// </summary>
        /// <param name="reader">The reader.</param>
        internal override void ReadElementsFromXml(EwsServiceXmlReader reader)
        {
            this.Rooms.Clear();
            base.ReadElementsFromXml(reader);

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

            if (!reader.IsEmptyElement)
            {
                // Because we don't have an element for count of returned object,
                // we have to test the element to determine if it is StartElement of return object or EndElement
                reader.Read();
                while (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.Room))
                {
                    reader.Read(); // skip the start <Room>

                    EmailAddress emailAddress = new EmailAddress();
                    emailAddress.LoadFromXml(reader, XmlElementNames.RoomId);
                    this.Rooms.Add(emailAddress);

                    reader.ReadEndElement(XmlNamespace.Types, XmlElementNames.Room);
                    reader.Read();
                }

                reader.EnsureCurrentNodeIsEndElement(XmlNamespace.Messages, XmlElementNames.Rooms);
            }
        }
        /// <summary>
        /// Reads response elements from XML.
        /// </summary>
        /// <param name="reader">The reader.</param>
        internal override void ReadElementsFromXml(EwsServiceXmlReader reader)
        {
            base.ReadElementsFromXml(reader);

            if (this.ErrorCode == ServiceError.NoError && reader.IsStartElement(XmlNamespace.NotSpecified, XmlElementNames.WasFirstInstall))
            {
                this.wasFirstInstall = reader.ReadElementValue<bool>(XmlNamespace.NotSpecified, XmlElementNames.WasFirstInstall);
            }
        }
    void ReadElementsFromXml(EwsServiceXmlReader reader)
    {
        base.ReadElementsFromXml(reader);

        if (this.ErrorCode == ServiceError.NoError && reader.IsStartElement(XmlNamespace.NotSpecified, XmlElementNames.WasFirstInstall))
        {
            this.wasFirstInstall = reader.ReadElementValue <bool>(XmlNamespace.NotSpecified, XmlElementNames.WasFirstInstall);
        }
    }
Beispiel #18
0
    bool TryReadElementFromXml(EwsServiceXmlReader reader)
    {
        switch (reader.LocalName)
        {
        case XmlElementNames.TimeZone:
            LegacyAvailabilityTimeZone legacyTimeZone = new LegacyAvailabilityTimeZone();
            legacyTimeZone.LoadFromXml(reader, reader.LocalName);

            this.timeZone = legacyTimeZone.ToTimeZoneInfo();

            return(true);

        case XmlElementNames.WorkingPeriodArray:
            List <WorkingPeriod> workingPeriods = new List <WorkingPeriod>();

            do
            {
                reader.Read();

                if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.WorkingPeriod))
                {
                    WorkingPeriod workingPeriod = new WorkingPeriod();

                    workingPeriod.LoadFromXml(reader, reader.LocalName);

                    workingPeriods.Add(workingPeriod);
                }
            }while (!reader.IsEndElement(XmlNamespace.Types, XmlElementNames.WorkingPeriodArray));

            // Availability supports a structure that can technically represent different working
            // times for each day of the week. This is apparently how the information is stored in
            // Exchange. However, no client (Outlook, OWA) either will let you specify different
            // working times for each day of the week, and Outlook won't either honor that complex
            // structure if it happens to be in Exchange.
            // So here we'll do what Outlook and OWA do: we'll use the start and end times of the
            // first working period, but we'll use the week days of all the periods.
            this.startTime = workingPeriods[0].StartTime;
            this.endTime   = workingPeriods[0].EndTime;

            for (WorkingPeriod workingPeriod in workingPeriods)
            {
                for (DayOfTheWeek dayOfWeek in workingPeriods[0].DaysOfWeek)
                {
                    if (!this.daysOfTheWeek.Contains(dayOfWeek))
                    {
                        this.daysOfTheWeek.Add(dayOfWeek);
                    }
                }
            }

            return(true);

        default:
            return(false);
        }
    }
        /// <summary>
        /// Tries to read element from XML.
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <returns>True if appropriate element was read.</returns>
        internal override bool TryReadElementFromXml(EwsServiceXmlReader reader)
        {
            switch (reader.LocalName)
            {
                case XmlElementNames.TimeZone:
                    LegacyAvailabilityTimeZone legacyTimeZone = new LegacyAvailabilityTimeZone();
                    legacyTimeZone.LoadFromXml(reader, reader.LocalName);

                    this.timeZone = legacyTimeZone.ToTimeZoneInfo();
                    
                    return true;
                case XmlElementNames.WorkingPeriodArray:
                    List<WorkingPeriod> workingPeriods = new List<WorkingPeriod>();

                    do
                    {
                        reader.Read();

                        if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.WorkingPeriod))
                        {
                            WorkingPeriod workingPeriod = new WorkingPeriod();

                            workingPeriod.LoadFromXml(reader, reader.LocalName);

                            workingPeriods.Add(workingPeriod);
                        }
                    }
                    while (!reader.IsEndElement(XmlNamespace.Types, XmlElementNames.WorkingPeriodArray));

                    // Availability supports a structure that can technically represent different working
                    // times for each day of the week. This is apparently how the information is stored in
                    // Exchange. However, no client (Outlook, OWA) either will let you specify different
                    // working times for each day of the week, and Outlook won't either honor that complex
                    // structure if it happens to be in Exchange.
                    // So here we'll do what Outlook and OWA do: we'll use the start and end times of the
                    // first working period, but we'll use the week days of all the periods.
                    this.startTime = workingPeriods[0].StartTime;
                    this.endTime = workingPeriods[0].EndTime;

                    foreach (WorkingPeriod workingPeriod in workingPeriods)
                    {
                        foreach (DayOfTheWeek dayOfWeek in workingPeriods[0].DaysOfWeek)
                        {
                            if (!this.daysOfTheWeek.Contains(dayOfWeek))
                            {
                                this.daysOfTheWeek.Add(dayOfWeek);
                            }
                        }
                    }

                    return true;
                default:
                    return false;
            }
        }
Beispiel #20
0
 /// <summary>
 /// Reads response elements from XML.
 /// </summary>
 /// <param name="reader">The reader.</param>
 internal override void ReadElementsFromXml(EwsServiceXmlReader reader)
 {
     reader.Read();
     this.ruleCollection.OutlookRuleBlobExists = reader.ReadElementValue <bool>(
         XmlNamespace.Messages,
         XmlElementNames.OutlookRuleBlobExists);
     reader.Read();
     if (reader.IsStartElement(XmlNamespace.NotSpecified, XmlElementNames.InboxRules))
     {
         this.ruleCollection.LoadFromXml(reader, XmlNamespace.NotSpecified, XmlElementNames.InboxRules);
     }
 }
 /// <summary>
 /// Reads response elements from XML.
 /// </summary>
 /// <param name="reader">The reader.</param>
 internal override void ReadElementsFromXml(EwsServiceXmlReader reader)
 {
     reader.Read();
     this.ruleCollection.OutlookRuleBlobExists = reader.ReadElementValue<bool>(
         XmlNamespace.Messages, 
         XmlElementNames.OutlookRuleBlobExists);
     reader.Read();
     if (reader.IsStartElement(XmlNamespace.NotSpecified, XmlElementNames.InboxRules))
     {
         this.ruleCollection.LoadFromXml(reader, XmlNamespace.NotSpecified, XmlElementNames.InboxRules);
     }
 }
        /// <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;
        }
Beispiel #23
0
 bool TryReadElementFromXml(EwsServiceXmlReader reader)
 {
     if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.Rule))
     {
         Rule rule = new Rule();
         rule.LoadFromXml(reader, XmlElementNames.Rule);
         this.rules.Add(rule);
         return(true);
     }
     else
     {
         return(false);
     }
 }
        /// <summary>
        /// Reads response elements from XML.
        /// </summary>
        /// <param name="reader">The reader.</param>
        internal override void ReadElementsFromXml(EwsServiceXmlReader reader)
        {
            base.ReadElementsFromXml(reader);

            reader.Read();

            if (reader.IsStartElement(XmlNamespace.Messages, XmlElementNames.MovedItemId))
            {
                this.MovedItemId = new ItemId();
                this.MovedItemId.LoadFromXml(reader, XmlNamespace.Messages, XmlElementNames.MovedItemId);

                reader.ReadEndElementIfNecessary(XmlNamespace.Messages, XmlElementNames.MovedItemId);
            }
        }
    void ReadElementsFromXml(EwsServiceXmlReader reader)
    {
        base.ReadElementsFromXml(reader);

        reader.Read();

        if (reader.IsStartElement(XmlNamespace.Messages, XmlElementNames.MovedItemId))
        {
            this.MovedItemId = new ItemId();
            this.MovedItemId.LoadFromXml(reader, XmlNamespace.Messages, XmlElementNames.MovedItemId);

            reader.ReadEndElementIfNecessary(XmlNamespace.Messages, XmlElementNames.MovedItemId);
        }
    }
    /// <summary>
    /// Load from xml
    /// </summary>
    /// <param name="reader">The reader</param>
    /// <returns>Non indexable item details result object</returns>
    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);
    }
    /// <summary>
    /// Load from xml
    /// </summary>
    /// <param name="reader">The reader</param>
    /// <returns>Mailbox hold object</returns>
    static MailboxHoldResult LoadFromXml(EwsServiceXmlReader reader)
    {
        List <MailboxHoldStatus> statuses = new List <MailboxHoldStatus>();

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

        MailboxHoldResult holdResult = new MailboxHoldResult();

        holdResult.HoldId = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.HoldId);

        // 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 MailboxHoldStatuses element
        reader.Read();
        holdResult.Query = "";
        if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.Query))
        {
            holdResult.Query = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.Query);
            reader.ReadStartElement(XmlNamespace.Types, XmlElementNames.MailboxHoldStatuses);
        }

        do
        {
            reader.Read();
            if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.MailboxHoldStatus))
            {
                String     mailbox        = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.Mailbox);
                HoldStatus status         = (HoldStatus)Enum.Parse(typeof(HoldStatus), reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.Status));
                String     additionalInfo = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.AdditionalInfo);
                statuses.Add(new MailboxHoldStatus(mailbox, status, additionalInfo));
            }
        }while (!reader.IsEndElement(XmlNamespace.Messages, XmlElementNames.MailboxHoldResult));

        holdResult.Statuses = statuses.Count == 0 ? null : statuses.ToArray();

        return(holdResult);
    }
        /// <summary>
        /// Reads response elements from XML.
        /// </summary>
        /// <param name="reader">The reader.</param>
        internal override void ReadElementsFromXml(EwsServiceXmlReader reader)
        {
            if (this.ErrorCode == ServiceError.NoError)
            {
                this.delegateUserResponses = new Collection<DelegateUserResponse>();

                reader.Read();

                if (reader.IsStartElement(XmlNamespace.Messages, XmlElementNames.ResponseMessages))
                {
                    int delegateUserIndex = 0;
                    do
                    {
                        reader.Read();

                        if (reader.IsStartElement(XmlNamespace.Messages, XmlElementNames.DelegateUserResponseMessageType))
                        {
                            DelegateUser delegateUser = null;
                            if (this.readDelegateUsers && (this.delegateUsers != null))
                            {
                                delegateUser = this.delegateUsers[delegateUserIndex];
                            }

                            DelegateUserResponse delegateUserResponse = new DelegateUserResponse(readDelegateUsers, delegateUser);

                            delegateUserResponse.LoadFromXml(reader, XmlElementNames.DelegateUserResponseMessageType);

                            this.delegateUserResponses.Add(delegateUserResponse);

                            delegateUserIndex++;
                        }
                    }
                    while (!reader.IsEndElement(XmlNamespace.Messages, XmlElementNames.ResponseMessages));
                }
            }
        }
    object ParseResponse(EwsServiceXmlReader reader)
    {
        GetUserAvailabilityResults serviceResponse = new GetUserAvailabilityResults();

        if (this.IsFreeBusyViewRequested)
        {
            serviceResponse.AttendeesAvailability = new ServiceResponseCollection <AttendeeAvailability>();

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

            do
            {
                reader.Read();

                if (reader.IsStartElement(XmlNamespace.Messages, XmlElementNames.FreeBusyResponse))
                {
                    AttendeeAvailability freeBusyResponse = new AttendeeAvailability();

                    freeBusyResponse.LoadFromXml(reader, XmlElementNames.ResponseMessage);

                    if (freeBusyResponse.ErrorCode == ServiceError.NoError)
                    {
                        freeBusyResponse.LoadFreeBusyViewFromXml(reader, this.Options.RequestedFreeBusyView);
                    }

                    serviceResponse.AttendeesAvailability.Add(freeBusyResponse);
                }
            }while (!reader.IsEndElement(XmlNamespace.Messages, XmlElementNames.FreeBusyResponseArray));
        }

        if (this.IsSuggestionsViewRequested)
        {
            serviceResponse.SuggestionsResponse = new SuggestionsResponse();

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

            serviceResponse.SuggestionsResponse.LoadFromXml(reader, XmlElementNames.ResponseMessage);

            if (serviceResponse.SuggestionsResponse.ErrorCode == ServiceError.NoError)
            {
                serviceResponse.SuggestionsResponse.LoadSuggestedDaysFromXml(reader);
            }

            reader.ReadEndElement(XmlNamespace.Messages, XmlElementNames.SuggestionsResponse);
        }

        return(serviceResponse);
    }
Beispiel #30
0
    /// <summary>
    /// Get collection of recipients
    /// </summary>
    /// <param name="reader">The reader</param>
    /// <param name="elementName">Element name</param>
    /// <returns>Array of recipients</returns>
    /* private */ static string[] GetRecipients(EwsServiceXmlReader reader, String elementName)
    {
        List <string> toRecipients = new List <string>();

        do
        {
            if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.SmtpAddress))
            {
                toRecipients.Add(reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.SmtpAddress));
            }

            reader.Read();
        }while (!reader.IsEndElement(XmlNamespace.Types, elementName));

        return(toRecipients.Count == 0 ? null : toRecipients.ToArray());
    }
Beispiel #31
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);
    }
Beispiel #32
0
    bool TryReadElementFromXml(EwsServiceXmlReader reader)
    {
        switch (reader.LocalName)
        {
        case XmlElementNames.Date:
            // The date that is returned by Availability is unscoped.
            DateTime tempDate = DateTime.Parse(reader.ReadElementValue <String>(), CultureInfo.InvariantCulture);

            if (tempDate.Kind != DateTimeKind.Unspecified)
            {
                this.date = new DateTime(tempDate.Ticks, DateTimeKind.Unspecified);
            }
            else
            {
                this.date = tempDate;
            }

            return(true);

        case XmlElementNames.DayQuality:
            this.quality = reader.ReadElementValue <SuggestionQuality>();
            return(true);

        case XmlElementNames.SuggestionArray:
            if (!reader.IsEmptyElement)
            {
                do
                {
                    reader.Read();

                    if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.Suggestion))
                    {
                        TimeSuggestion timeSuggestion = new TimeSuggestion();

                        timeSuggestion.LoadFromXml(reader, reader.LocalName);

                        this.timeSuggestions.Add(timeSuggestion);
                    }
                }while (!reader.IsEndElement(XmlNamespace.Types, XmlElementNames.SuggestionArray));
            }

            return(true);

        default:
            return(false);
        }
    }
Beispiel #33
0
    /// <summary>
    /// Extracts a dictionary object (key or entry value) as a String list from the
    /// specified reader.
    /// </summary>
    /// <param name="reader">The reader.</param>
    /// <param name="type">The object type.</param>
    /// <returns>String list representing a dictionary object.</returns>
    /* private */ List <string> GetObjectValue(EwsServiceXmlReader reader, UserConfigurationDictionaryObjectType type)
    {
        EwsUtilities.Assert(
            reader != null,
            "UserConfigurationDictionary.LoadFromXml",
            "reader is null");

        List <string> values = new List <string>();

        reader.ReadStartElement(this.Namespace, XmlElementNames.Value);

        do
        {
            String value = null;

            if (reader.IsEmptyElement)
            {
                // Only String types can be represented with empty values.
                switch (type)
                {
                case UserConfigurationDictionaryObjectType.String:
                case UserConfigurationDictionaryObjectType.StringArray:
                    value = "";
                    break;

                default:
                    EwsUtilities.Assert(
                        false,
                        "UserConfigurationDictionary.GetObjectValue",
                        "Empty element passed for type: " + type.ToString());
                    break;
                }
            }
            else
            {
                value = reader.ReadElementValue();
            }

            values.Add(value);

            reader.Read();     // Position at next element or DictionaryKey/DictionaryValue end element
        }while (reader.IsStartElement(this.Namespace, XmlElementNames.Value));

        return(values);
    }
Beispiel #34
0
        /// <summary>
        /// Tries to read element from XML.
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <returns>True if appropriate element was read.</returns>
        internal override bool TryReadElementFromXml(EwsServiceXmlReader reader)
        {
            switch (reader.LocalName)
            {
                case XmlElementNames.Date:
                    // The date that is returned by Availability is unscoped. 
                    DateTime tempDate = DateTime.Parse(reader.ReadElementValue(), CultureInfo.InvariantCulture);

                    if (tempDate.Kind != DateTimeKind.Unspecified)
                    {
                        this.date = new DateTime(tempDate.Ticks, DateTimeKind.Unspecified);
                    }
                    else
                    {
                        this.date = tempDate;
                    }

                    return true;
                case XmlElementNames.DayQuality:
                    this.quality = reader.ReadElementValue<SuggestionQuality>();
                    return true;
                case XmlElementNames.SuggestionArray:
                    if (!reader.IsEmptyElement)
                    {
                        do
                        {
                            reader.Read();

                            if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.Suggestion))
                            {
                                TimeSuggestion timeSuggestion = new TimeSuggestion();

                                timeSuggestion.LoadFromXml(reader, reader.LocalName);

                                this.timeSuggestions.Add(timeSuggestion);
                            }
                        }
                        while (!reader.IsEndElement(XmlNamespace.Types, XmlElementNames.SuggestionArray));
                    }

                    return true;
                default:
                    return false;
            }
        }
Beispiel #35
0
    /// <summary>
    /// Loads the suggested days from XML.
    /// </summary>
    /// <param name="reader">The reader.</param>
    void LoadSuggestedDaysFromXml(EwsServiceXmlReader reader)
    {
        reader.ReadStartElement(XmlNamespace.Messages, XmlElementNames.SuggestionDayResultArray);

        do
        {
            reader.Read();

            if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.SuggestionDayResult))
            {
                Suggestion daySuggestion = new Suggestion();

                daySuggestion.LoadFromXml(reader, reader.LocalName);

                this.daySuggestions.Add(daySuggestion);
            }
        }while (!reader.IsEndElement(XmlNamespace.Messages, XmlElementNames.SuggestionDayResultArray));
    }
        /// <summary>
        /// Loads the suggested days from XML.
        /// </summary>
        /// <param name="reader">The reader.</param>
        internal void LoadSuggestedDaysFromXml(EwsServiceXmlReader reader)
        {
            reader.ReadStartElement(XmlNamespace.Messages, XmlElementNames.SuggestionDayResultArray);

            do
            {
                reader.Read();

                if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.SuggestionDayResult))
                {
                    Suggestion daySuggestion = new Suggestion();

                    daySuggestion.LoadFromXml(reader, reader.LocalName);

                    this.daySuggestions.Add(daySuggestion);
                }
            }
            while (!reader.IsEndElement(XmlNamespace.Messages, XmlElementNames.SuggestionDayResultArray));
        }
Beispiel #37
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());
    }
Beispiel #38
0
    void ReadElementsFromXml(EwsServiceXmlReader reader)
    {
        this.configurations.Clear();

        base.ReadElementsFromXml(reader);

        reader.ReadStartElement(XmlNamespace.Messages, XmlElementNames.DiscoverySearchConfigurations);
        if (!reader.IsEmptyElement)
        {
            do
            {
                reader.Read();
                if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.DiscoverySearchConfiguration))
                {
                    this.configurations.Add(DiscoverySearchConfiguration.LoadFromXml(reader));
                }
            }while (!reader.IsEndElement(XmlNamespace.Messages, XmlElementNames.DiscoverySearchConfigurations));
        }
        reader.ReadEndElementIfNecessary(XmlNamespace.Messages, XmlElementNames.DiscoverySearchConfigurations);
    }
Beispiel #39
0
    void ReadElementsFromXml(EwsServiceXmlReader reader)
    {
        this.retentionPolicyTags.Clear();

        base.ReadElementsFromXml(reader);

        reader.ReadStartElement(XmlNamespace.Messages, XmlElementNames.RetentionPolicyTags);
        if (!reader.IsEmptyElement)
        {
            do
            {
                reader.Read();
                if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.RetentionPolicyTag))
                {
                    this.retentionPolicyTags.Add(RetentionPolicyTag.LoadFromXml(reader));
                }
            }while (!reader.IsEndElement(XmlNamespace.Messages, XmlElementNames.RetentionPolicyTags));
            reader.ReadEndElementIfNecessary(XmlNamespace.Messages, XmlElementNames.RetentionPolicyTags);
        }
    }
Beispiel #40
0
    /// <summary>
    /// Read the response from Exchange 2013.
    /// This method assumes that the reader is currently at the Manifests element.
    /// </summary>
    /// <param name="reader">The reader.</param>
    /* private */ void ReadFromExchange2013(EwsServiceXmlReader reader)
    {
        ////<GetAppManifestsResponse ResponseClass="Success" xmlns="http://schemas.microsoft.com/exchange/services/2006/messages">
        ////<ResponseCode>NoError</ResponseCode>
        ////<m:Manifests xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages">
        ////<m:Manifest>[base 64 encoded manifest]</m:Manifest>                              <--- reader should be at this node at the beginning of loop
        ////<m:Manifest>[base 64 encoded manifest]</m:Manifest>
        //// ....
        ////</m:Manifests>                                                                   <--- reader should be at this node at the end of the loop
        while (reader.IsStartElement(XmlNamespace.Messages, XmlElementNames.Manifest))
        {
            XmlDocument manifest = ClientApp.ReadToXmlDocument(reader);
            this.Manifests.Add(manifest);

            this.Apps.Add(new ClientApp()
            {
                Manifest = manifest
            });
        }
    }
    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>
        /// Reads response elements from XML.
        /// </summary>
        /// <param name="reader">The reader.</param>
        internal override void ReadElementsFromXml(EwsServiceXmlReader reader)
        {
            base.ReadElementsFromXml(reader);

            if (this.ErrorCode == ServiceError.NoError)
            {
                // If there were no response messages, the reader will already be on the
                // DeliverMeetingRequests start element, so we don't need to read it.
                if (this.DelegateUserResponses.Count > 0)
                {
                    reader.Read();
                }

                // Make sure that we're at the DeliverMeetingRequests element before trying to read the value.
                // In error cases, the element may not have been returned.
                if (reader.IsStartElement(XmlNamespace.Messages, XmlElementNames.DeliverMeetingRequests))
                {
                    this.meetingRequestsDeliveryScope = reader.ReadElementValue<MeetingRequestsDeliveryScope>();
                }
            }
        }
        /// <summary>
        /// Reads response elements from XML.
        /// </summary>
        /// <param name="reader">The reader.</param>
        internal override void ReadElementsFromXml(EwsServiceXmlReader reader)
        {
            responseCollection = new ServiceResponseCollection <MailTipsResponseMessage>();
            base.ReadElementsFromXml(reader);
            reader.ReadStartElement(XmlNamespace.Messages, XmlElementNames.ResponseMessages);

            if (!reader.IsEmptyElement)
            {
                // Because we don't have count of returned objects
                // test the element to determine if it is return object or EndElement
                reader.Read();
                while (reader.IsStartElement(XmlNamespace.Messages, XmlElementNames.MailTipsResponseMessageType))
                {
                    MailTipsResponseMessage mrm = new MailTipsResponseMessage();
                    mrm.LoadFromXml(reader, XmlElementNames.MailTipsResponseMessageType);
                    this.responseCollection.Add(mrm);
                    reader.Read();
                }
                reader.EnsureCurrentNodeIsEndElement(XmlNamespace.Messages, XmlElementNames.ResponseMessages);
            }
        }
        /// <summary>
        /// Reads response elements from XML.
        /// </summary>
        /// <param name="reader">The reader.</param>
        internal override void ReadElementsFromXml(EwsServiceXmlReader reader)
        {
            this.retentionPolicyTags.Clear();

            base.ReadElementsFromXml(reader);

            reader.ReadStartElement(XmlNamespace.Messages, XmlElementNames.RetentionPolicyTags);
            if (!reader.IsEmptyElement)
            {
                do
                {
                    reader.Read();
                    if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.RetentionPolicyTag))
                    {
                        this.retentionPolicyTags.Add(RetentionPolicyTag.LoadFromXml(reader));
                    }
                }
                while (!reader.IsEndElement(XmlNamespace.Messages, XmlElementNames.RetentionPolicyTags));
                reader.ReadEndElementIfNecessary(XmlNamespace.Messages, XmlElementNames.RetentionPolicyTags);
            }
        }
        /// <summary>
        /// Reads response elements from XML.
        /// </summary>
        /// <param name="reader">The reader.</param>
        internal override void ReadElementsFromXml(EwsServiceXmlReader reader)
        {
            this.configurations.Clear();

            base.ReadElementsFromXml(reader);

            reader.ReadStartElement(XmlNamespace.Messages, XmlElementNames.DiscoverySearchConfigurations);
            if (!reader.IsEmptyElement)
            {
                do
                {
                    reader.Read();
                    if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.DiscoverySearchConfiguration))
                    {
                        this.configurations.Add(DiscoverySearchConfiguration.LoadFromXml(reader));
                    }
                }
                while (!reader.IsEndElement(XmlNamespace.Messages, XmlElementNames.DiscoverySearchConfigurations));
            }
            reader.ReadEndElementIfNecessary(XmlNamespace.Messages, XmlElementNames.DiscoverySearchConfigurations);
        }
        /// <summary>
        /// Reads response elements from XML.
        /// </summary>
        /// <param name="reader">The reader.</param>
        internal override void ReadElementsFromXml(EwsServiceXmlReader reader)
        {
            responseCollection = new ServiceResponseCollection<MailTipsResponseMessage>();
            base.ReadElementsFromXml(reader);
            reader.ReadStartElement(XmlNamespace.Messages, XmlElementNames.ResponseMessages);

            if (!reader.IsEmptyElement)
            {
                // Because we don't have count of returned objects
                // test the element to determine if it is return object or EndElement
                reader.Read();
                while (reader.IsStartElement(XmlNamespace.Messages, XmlElementNames.MailTipsResponseMessageType))
                {
                    MailTipsResponseMessage mrm = new MailTipsResponseMessage();
                    mrm.LoadFromXml(reader, XmlElementNames.MailTipsResponseMessageType);
                    this.responseCollection.Add(mrm);
                    reader.Read();
                }
                reader.EnsureCurrentNodeIsEndElement(XmlNamespace.Messages, XmlElementNames.ResponseMessages);
            }
        }
Beispiel #47
0
    void ReadElementsFromXml(EwsServiceXmlReader reader)
    {
        base.ReadElementsFromXml(reader);

        if (this.ErrorCode == ServiceError.NoError)
        {
            // If there were no response messages, the reader will already be on the
            // DeliverMeetingRequests start element, so we don't need to read it.
            if (this.DelegateUserResponses.Count > 0)
            {
                reader.Read();
            }

            // Make sure that we're at the DeliverMeetingRequests element before trying to read the value.
            // In error cases, the element may not have been returned.
            if (reader.IsStartElement(XmlNamespace.Messages, XmlElementNames.DeliverMeetingRequests))
            {
                this.meetingRequestsDeliveryScope = reader.ReadElementValue <MeetingRequestsDeliveryScope>();
            }
        }
    }
Beispiel #48
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();
    }
        /// <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>
         internal override void ReadElementsFromXml(EwsServiceXmlReader reader)
         {
             this.groupsSets.Clear();
             base.ReadElementsFromXml(reader);

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

             if (!reader.IsEmptyElement)
             {
                 reader.Read();
                 while (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.UnifiedGroupsSet))
                 {
                     UnifiedGroupsSet unifiedGroupsSet = new UnifiedGroupsSet();
                     unifiedGroupsSet.LoadFromXml(reader, XmlElementNames.UnifiedGroupsSet);
                     this.groupsSets.Add(unifiedGroupsSet);
                 }

                 // Skip end element GroupsSets
                 reader.EnsureCurrentNodeIsEndElement(XmlNamespace.NotSpecified, XmlElementNames.GroupsSets);
                 reader.Read();
             }
         }
        /// <summary>
        /// Read Conversations from XML.
        /// </summary>
        /// <param name="reader">The reader.</param>
        internal override void ReadElementsFromXml(EwsServiceXmlReader reader)
        {
            this.groupsSets.Clear();
            base.ReadElementsFromXml(reader);

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

            if (!reader.IsEmptyElement)
            {
                reader.Read();
                while (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.UnifiedGroupsSet))
                {
                    UnifiedGroupsSet unifiedGroupsSet = new UnifiedGroupsSet();
                    unifiedGroupsSet.LoadFromXml(reader, XmlElementNames.UnifiedGroupsSet);
                    this.groupsSets.Add(unifiedGroupsSet);
                }

                // Skip end element GroupsSets
                reader.EnsureCurrentNodeIsEndElement(XmlNamespace.NotSpecified, XmlElementNames.GroupsSets);
                reader.Read();
            }
        }
        /// <summary>
        /// Reads response elements from XML.
        /// </summary>
        /// <param name="reader">The reader.</param>
        internal override void ReadElementsFromXml(EwsServiceXmlReader reader)
        {
            base.ReadElementsFromXml(reader);

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

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

                    if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.TimeZoneDefinition))
                    {
                        TimeZoneDefinition timeZoneDefinition = new TimeZoneDefinition();
                        timeZoneDefinition.LoadFromXml(reader);

                        this.timeZones.Add(timeZoneDefinition.ToTimeZoneInfo(reader.Service));
                    }
                }
                while (!reader.IsEndElement(XmlNamespace.Messages, XmlElementNames.TimeZoneDefinitions));
            }
        }
        /// <summary>
        /// Read the response from Exchange 2013.
        /// This method assumes that the reader is currently at the Manifests element.
        /// </summary>
        /// <param name="reader">The reader.</param>
        private void ReadFromExchange2013(EwsServiceXmlReader reader)
        {
            ////<GetAppManifestsResponse ResponseClass="Success" xmlns="http://schemas.microsoft.com/exchange/services/2006/messages">
            ////<ResponseCode>NoError</ResponseCode>
            ////<m:Manifests xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages">   
            ////<m:Manifest>[base 64 encoded manifest]</m:Manifest>                              <--- reader should be at this node at the beginning of loop
            ////<m:Manifest>[base 64 encoded manifest]</m:Manifest>
            //// ....
            ////</m:Manifests>                                                                   <--- reader should be at this node at the end of the loop
            while (reader.IsStartElement(XmlNamespace.Messages, XmlElementNames.Manifest))
            {
                XmlDocument manifest = ClientApp.ReadToXmlDocument(reader);
                this.Manifests.Add(manifest);

                this.Apps.Add(new ClientApp() { Manifest = manifest });
            }
        }
        /// <summary>
        /// Read the response from Exchange 2013.
        /// This method assumes that the reader is currently at the Manifests element.
        /// </summary>
        /// <param name="reader">The reader.</param>
        private void ReadFromExchange2013Sp1(EwsServiceXmlReader reader)
        {
            ////<GetAppManifestsResponse ResponseClass="Success" xmlns="http://schemas.microsoft.com/exchange/services/2006/messages">
            ////  <ResponseCode>NoError</ResponseCode>
            ////  <m:Apps xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages">
            ////    <t:App xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">       <--- reader should be at this node at the beginning of the loop
            ////      <t:Metadata>
            ////        <t:EndNodeUrl>http://o15.officeredir.microsoft.com/r/rlidMktplcExchRedirect?app=outlook.exe&amp;ver=15&amp;clid=1033&amp;p1=15d0d766d0&amp;p2=4&amp;p3=0&amp;p4=WA&amp;p5=en-US\WA102996382&amp;Scope=2&amp;CallBackURL=https%3a%2f%2fexhv-4880%2fecp%2fExtension%2finstallFromURL.slab%3fexsvurl%3d1&amp;DeployId=EXHV-4680dom.extest.microsoft.com</t:EndNodeUrl>
            ////        <t:AppStatus>2.3</t:AppStatus>
            ////        <t:ActionUrl>http://o15.officeredir.microsoft.com/r/rlidMktplcExchRedirect?app=outlook.exe&amp;ver=15&amp;clid=1033&amp;p1=15d0d766d0&amp;p2=4&amp;p3=0&amp;p4=WA&amp;p5=en-US\WA102996382&amp;Scope=2&amp;CallBackURL=https%3a%2f%2fexhv-4880%2fecp%2fExtension%2finstallFromURL.slab%3fexsvurl%3d1&amp;DeployId=EXHV-4680dom.extest.microsoft.com</t:ActionUrl>
            ////      </t:Metadata>
            ////      <t:Manifest>[base 64 encoded manifest]</t:Manifest>
            ////    </t:App>
            ////    <t:App xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
            ////      ....
            ////  <m:Apps>    <----- reader should be at this node at the end of the loop
            while (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.App))
            {
                ClientApp clientApp = new ClientApp();
                clientApp.LoadFromXml(reader, XmlElementNames.App);

                this.Apps.Add(clientApp);
                this.Manifests.Add(clientApp.Manifest);

                reader.EnsureCurrentNodeIsEndElement(XmlNamespace.Types, XmlElementNames.App);
                reader.Read();
            }
        }
        /// <summary>
        /// Read Personas from XML.
        /// </summary>
        /// <param name="reader">The reader.</param>
        internal override void ReadElementsFromXml(EwsServiceXmlReader reader)
        {
            EwsUtilities.Assert(
                   this.Results.Personas != null,
                   "FindPeopleResponse.ReadElementsFromXml",
                   "Personas is null.");

            reader.ReadStartElement(XmlNamespace.Messages, XmlElementNames.People);
            if (!reader.IsEmptyElement)
            {
                do
                {
                    reader.Read();

                    if (reader.NodeType == XmlNodeType.Element)
                    {
                        Persona item = EwsUtilities.CreateEwsObjectFromXmlElementName<Persona>(reader.Service, reader.LocalName);

                        if (item == null)
                        {
                            reader.SkipCurrentElement();
                        }
                        else
                        {
                            // Don't clear propertyBag because all properties have been initialized in the persona constructor.
                            item.LoadFromXml(reader, false, null, false);
                            this.Results.Personas.Add(item);
                        }
                    }
                }
                while (!reader.IsEndElement(XmlNamespace.Messages, XmlElementNames.People));
            }

            reader.Read();

            if (reader.IsStartElement(XmlNamespace.Messages, XmlElementNames.TotalNumberOfPeopleInView) && !reader.IsEmptyElement)
            {
                this.Results.TotalCount = reader.ReadElementValue<int>();
                reader.Read();
            }

            if (reader.IsStartElement(XmlNamespace.Messages, XmlElementNames.FirstMatchingRowIndex) && !reader.IsEmptyElement)
            {
                this.Results.FirstMatchingRowIndex = reader.ReadElementValue<int>();
                reader.Read();
            }

            if (reader.IsStartElement(XmlNamespace.Messages, XmlElementNames.FirstLoadedRowIndex) && !reader.IsEmptyElement)
            {
                this.Results.FirstLoadedRowIndex = reader.ReadElementValue<int>();
                reader.Read();
            }

            if (reader.IsStartElement(XmlNamespace.Messages, XmlElementNames.FindPeopleTransactionId) && !reader.IsEmptyElement)
            {
                this.TransactionId = reader.ReadElementValue<string>();
                reader.Read();
            }
   
            // Future proof by skipping any additional elements before returning
            while (!reader.IsEndElement(XmlNamespace.Messages, XmlElementNames.FindPeopleResponse))
            {
                reader.Read();
            }
        }
        /// <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;
            }
        }
         /// <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();
         }
        /// <summary>
        /// Extracts a dictionary object (key or entry value) as a string list from the
        /// specified reader.
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <param name="type">The object type.</param>
        /// <returns>String list representing a dictionary object.</returns>
        private List<string> GetObjectValue(EwsServiceXmlReader reader, UserConfigurationDictionaryObjectType type)
        {
            EwsUtilities.Assert(
                reader != null,
                "UserConfigurationDictionary.LoadFromXml",
                "reader is null");

            List<string> values = new List<string>();

            reader.ReadStartElement(this.Namespace, XmlElementNames.Value);

            do
            {
                string value = null;

                if (reader.IsEmptyElement)
                {
                    // Only string types can be represented with empty values.
                    switch (type)
                    {
                        case UserConfigurationDictionaryObjectType.String:
                        case UserConfigurationDictionaryObjectType.StringArray:
                            value = string.Empty;
                            break;
                        default:
                            EwsUtilities.Assert(
                                false,
                                "UserConfigurationDictionary.GetObjectValue",
                                "Empty element passed for type: " + type.ToString());
                            break;
                    }
                }
                else
                {
                    value = reader.ReadElementValue();
                }

                values.Add(value);

                reader.Read(); // Position at next element or DictionaryKey/DictionaryValue end element
            }
            while (reader.IsStartElement(this.Namespace, XmlElementNames.Value));

            return values;
        }
        /// <summary>
        /// Load from xml
        /// </summary>
        /// <param name="reader">The reader</param>
        /// <returns>Mailbox hold object</returns>
        internal static MailboxHoldResult LoadFromXml(EwsServiceXmlReader reader)
        {
            List<MailboxHoldStatus> statuses = new List<MailboxHoldStatus>();

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

            MailboxHoldResult holdResult = new MailboxHoldResult();
            holdResult.HoldId = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.HoldId);

            // 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 MailboxHoldStatuses element
            reader.Read();
            holdResult.Query = string.Empty;
            if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.Query))
            {
                holdResult.Query = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.Query);
                reader.ReadStartElement(XmlNamespace.Types, XmlElementNames.MailboxHoldStatuses);
            }

            do
            {
                reader.Read();
                if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.MailboxHoldStatus))
                {
                    string mailbox = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.Mailbox);
                    HoldStatus status = (HoldStatus)Enum.Parse(typeof(HoldStatus), reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.Status));
                    string additionalInfo = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.AdditionalInfo);
                    statuses.Add(new MailboxHoldStatus(mailbox, status, additionalInfo));
                }
            }
            while (!reader.IsEndElement(XmlNamespace.Messages, XmlElementNames.MailboxHoldResult));

            holdResult.Statuses = statuses.Count == 0 ? null : statuses.ToArray();

            return holdResult;
        }
        /// <summary>
        /// Loads extra error details from XML
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <param name="xmlElementName">The current element name of the extra error details.</param>
        /// <returns>
        /// True if the expected extra details is loaded;
        /// False if the element name does not match the expected element.
        /// </returns>
        internal override bool LoadExtraErrorDetailsFromXml(EwsServiceXmlReader reader, string xmlElementName)
        {
            bool baseReturnVal = base.LoadExtraErrorDetailsFromXml(reader, xmlElementName);

            if (reader.IsStartElement(XmlNamespace.Messages, XmlElementNames.ErrorSubscriptionIds))
            {
                do
                {
                    reader.Read();

                    if (reader.NodeType == System.Xml.XmlNodeType.Element &&
                        reader.LocalName == XmlElementNames.SubscriptionId)
                    {
                        this.ErrorSubscriptionIds.Add(
                            reader.ReadElementValue(XmlNamespace.Messages, XmlElementNames.SubscriptionId));
                    }
                }
                while (!reader.IsEndElement(XmlNamespace.Messages, XmlElementNames.ErrorSubscriptionIds));

                return true;
            }
            else
            {
                return baseReturnVal;
            }
        }