/// <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.LocationDisplayName:
                this.displayName = reader.ReadValue <string>();
                return(true);

            case XmlElementNames.LocationAnnotation:
                this.annotation = reader.ReadValue <string>();
                return(true);

            case XmlElementNames.PersonaPostalAddress:
                this.personaPostalAddress = new PersonaPostalAddress();
                this.personaPostalAddress.LoadFromXml(reader);
                this.personaPostalAddress.OnChange += new ComplexPropertyChangedDelegate(PersonaPostalAddress_OnChange);
                return(true);

            default:
                return(false);
            }
        }
Пример #2
0
        /// <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>
        /// Reads response elements from XML.
        /// </summary>
        /// <param name="reader">The reader.</param>
        internal override void ReadElementsFromXml(EwsServiceXmlReader reader)
        {
            base.ReadElementsFromXml(reader);

            reader.ReadServiceObjectsCollectionFromXml <Item>(
                XmlElementNames.Items,
                this.GetObjectInstance,
                false,  /* clearPropertyBag */
                null,   /* requestedPropertySet */
                false); /* summaryPropertiesOnly */

            // ConflictResults was only added in 2007 SP1 so if this was a 2007 RTM request we shouldn't expect to find the element
            if (!reader.Service.Exchange2007CompatibilityMode)
            {
                reader.ReadStartElement(XmlNamespace.Messages, XmlElementNames.ConflictResults);
                this.conflictCount = reader.ReadElementValue <int>(XmlNamespace.Types, XmlElementNames.Count);
                reader.ReadEndElement(XmlNamespace.Messages, XmlElementNames.ConflictResults);
            }

            // If UpdateItem returned an item that has the same Id as the item that
            // is being updated, this is a "normal" UpdateItem operation, and we need
            // to update the ChangeKey of the item being updated with the one that was
            // returned. Also set returnedItem to indicate that no new item was returned.
            //
            // Otherwise, this in a "special" UpdateItem operation, such as a recurring
            // task marked as complete (the returned item in that case is the one-off
            // task that represents the completed instance).
            //
            // Note that there can be no returned item at all, as in an UpdateItem call
            // with MessageDisposition set to SendOnly or SendAndSaveCopy.
            if (this.returnedItem != null)
            {
                if (this.item.Id.UniqueId == this.returnedItem.Id.UniqueId)
                {
                    this.item.Id.ChangeKey = this.returnedItem.Id.ChangeKey;
                    this.returnedItem      = null;
                }
            }
        }
        /// <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.BaseOffset:
                this.baseOffset = EwsUtilities.XSDurationToTimeSpan(reader.ReadElementValue());
                return(true);

            case XmlElementNames.Standard:
                this.standard = new TimeChange();
                this.standard.LoadFromXml(reader, reader.LocalName);
                return(true);

            case XmlElementNames.Daylight:
                this.daylight = new TimeChange();
                this.daylight.LoadFromXml(reader, reader.LocalName);
                return(true);

            default:
                return(false);
            }
        }
Пример #5
0
        /// <summary>
        /// Read items from XML.
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <param name="propertySet">The property set.</param>
        /// <param name="destinationList">The list in which to add the read items.</param>
        private static void InternalReadItemsFromXml(
            EwsServiceXmlReader reader,
            PropertySet propertySet,
            IList <TItem> destinationList)
        {
            EwsUtilities.Assert(
                destinationList != null,
                "FindItemResponse.InternalReadItemsFromXml",
                "destinationList is null.");

            reader.ReadStartElement(XmlNamespace.Types, XmlElementNames.Items);
            if (!reader.IsEmptyElement)
            {
                do
                {
                    reader.Read();

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

                        if (item == null)
                        {
                            reader.SkipCurrentElement();
                        }
                        else
                        {
                            item.LoadFromXml(
                                reader,
                                true,         /* clearPropertyBag */
                                propertySet,
                                true /* summaryPropertiesOnly */);

                            destinationList.Add(item);
                        }
                    }
                }while (!reader.IsEndElement(XmlNamespace.Types, XmlElementNames.Items));
            }
        }
        /// <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.ConversationId:
                this.ConversationId = new ConversationId();
                this.ConversationId.LoadFromXml(reader, XmlElementNames.ConversationId);
                return(true);

            case XmlElementNames.SyncState:
                this.SyncState = reader.ReadElementValue();
                return(true);

            case XmlElementNames.ConversationNodes:
                this.ConversationNodes = new ConversationNodeCollection(this.propertySet);
                this.ConversationNodes.LoadFromXml(reader, XmlElementNames.ConversationNodes);
                return(true);

            default:
                return(false);
            }
        }
        /// <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.Bias:
                this.bias = TimeSpan.FromMinutes(reader.ReadElementValue <int>());
                return(true);

            case XmlElementNames.StandardTime:
                this.standardTime = new LegacyAvailabilityTimeZoneTime();
                this.standardTime.LoadFromXml(reader, reader.LocalName);
                return(true);

            case XmlElementNames.DaylightTime:
                this.daylightTime = new LegacyAvailabilityTimeZoneTime();
                this.daylightTime.LoadFromXml(reader, reader.LocalName);
                return(true);

            default:
                return(false);
            }
        }
Пример #8
0
        /// <summary>
        /// Parses the message XML.
        /// </summary>
        /// <param name="reader">The reader.</param>
        private void ParseMessageXml(EwsServiceXmlReader reader)
        {
            do
            {
                reader.Read();

                if (reader.IsStartElement())
                {
                    switch (reader.LocalName)
                    {
                        case XmlElementNames.Value:
                            this.errorDetails.Add(reader.ReadAttributeValue(XmlAttributeNames.Name), reader.ReadElementValue());
                            break;

                        case XmlElementNames.FieldURI:
                            this.errorProperties.Add(ServiceObjectSchema.FindPropertyDefinition(reader.ReadAttributeValue(XmlAttributeNames.FieldURI)));
                            break;

                        case XmlElementNames.IndexedFieldURI:
                            this.errorProperties.Add(
                                new IndexedPropertyDefinition(
                                    reader.ReadAttributeValue(XmlAttributeNames.FieldURI),
                                    reader.ReadAttributeValue(XmlAttributeNames.FieldIndex)));
                            break;

                        case XmlElementNames.ExtendedFieldURI:
                            ExtendedPropertyDefinition extendedPropDef = new ExtendedPropertyDefinition();
                            extendedPropDef.LoadFromXml(reader);
                            this.errorProperties.Add(extendedPropDef);
                            break;

                        default:
                            break;
                    }
                }
            }
            while (!reader.IsEndElement(XmlNamespace.Messages, XmlElementNames.MessageXml));
        }
        /// <summary>
        /// Loads from XML.
        /// </summary>
        /// <param name="reader">The reader.</param>
        internal void LoadFromXml(EwsServiceXmlReader reader)
        {
            reader.ReadStartElement(XmlNamespace.Messages, XmlElementNames.ResolutionSet);

            // Note: TotalItemsInView is not reliable, https://github.com/OfficeDev/ews-managed-api/issues/177
            this.includesAllResolutions = reader.ReadAttributeValue <bool>(XmlAttributeNames.IncludesLastItemInRange);

            NameResolution nameResolution;

            while (true)
            {
                nameResolution = new NameResolution(this);

                if (!nameResolution.LoadFromXml(reader, true))
                {
                    break;
                }

                this.items.Add(nameResolution);
            }

            reader.EnsureCurrentNodeIsEndElement(XmlNamespace.Messages, XmlElementNames.ResolutionSet);
        }
            /// <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)
            {
                if (base.TryReadElementFromXml(reader))
                {
                    return(true);
                }
                else
                {
                    switch (reader.LocalName)
                    {
                    case XmlElementNames.DaysOfWeek:
                        this.dayOfTheWeek = reader.ReadElementValue <DayOfTheWeek>();
                        return(true);

                    case XmlElementNames.DayOfWeekIndex:
                        this.dayOfTheWeekIndex = reader.ReadElementValue <DayOfTheWeekIndex>();
                        return(true);

                    default:
                        return(false);
                    }
                }
            }
Пример #11
0
        /// <summary>
        /// Read Person from XML.
        /// </summary>
        /// <param name="reader">The reader.</param>
        internal override void ReadElementsFromXml(EwsServiceXmlReader reader)
        {
            EwsUtilities.Assert(
                this.People != null,
                "GetPeopleInsightsResponse.ReadElementsFromXml",
                "People is null.");

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

                    if (reader.NodeType == XmlNodeType.Element)
                    {
                        Person item = new Person();
                        item.LoadFromXml(reader, XmlNamespace.Types, XmlElementNames.Person);
                        this.People.Add(item);
                    }
                }while (!reader.IsEndElement(XmlNamespace.Messages, XmlElementNames.People));
            }
        }
Пример #12
0
        /// <summary>
        /// Loads a notification event from XML.
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <param name="eventElementName">Name of the event XML element.</param>
        /// <param name="eventType">Type of the event.</param>
        private void LoadNotificationEventFromXml(
            EwsServiceXmlReader reader,
            string eventElementName,
            EventType eventType)
        {
            DateTime timestamp = reader.ReadElementValue <DateTime>(XmlNamespace.Types, XmlElementNames.TimeStamp);

            NotificationEvent notificationEvent;

            reader.Read();

            if (reader.LocalName == XmlElementNames.FolderId)
            {
                notificationEvent = new FolderEvent(eventType, timestamp);
            }
            else
            {
                notificationEvent = new ItemEvent(eventType, timestamp);
            }

            notificationEvent.LoadFromXml(reader, eventElementName);
            this.events.Add(notificationEvent);
        }
        /// <summary>
        /// Loads from XML.
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <param name="localElementName">Name of the local element.</param>
        internal override void LoadFromXml(EwsServiceXmlReader reader, string localElementName)
        {
            reader.EnsureCurrentNodeIsStartElement(XmlNamespace.Types, localElementName);

            reader.ReadStartElement(XmlNamespace.Types, this.InnerCollectionXmlElementName);
            base.LoadFromXml(reader, this.InnerCollectionXmlElementName);
            reader.ReadEndElementIfNecessary(XmlNamespace.Types, this.InnerCollectionXmlElementName);

            reader.Read();

            if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.UnknownEntries))
            {
                do
                {
                    reader.Read();

                    if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.UnknownEntry))
                    {
                        this.unknownEntries.Add(reader.ReadElementValue());
                    }
                }while (!reader.IsEndElement(XmlNamespace.Types, XmlElementNames.UnknownEntries));
            }
        }
        /// <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>
            /// 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)
            {
                if (base.TryReadElementFromXml(reader))
                {
                    return(true);
                }
                else
                {
                    switch (reader.LocalName)
                    {
                    case XmlElementNames.DayOfMonth:
                        this.dayOfMonth = reader.ReadElementValue <int>();
                        return(true);

                    case XmlElementNames.Month:
                        this.month = reader.ReadElementValue <Month>();
                        return(true);

                    default:
                        return(false);
                    }
                }
            }
Пример #16
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.DayOfWeek:
                EwsUtilities.ParseEnumValueList <DayOfTheWeek>(
                    this.daysOfWeek,
                    reader.ReadElementValue(),
                    ' ');
                return(true);

            case XmlElementNames.StartTimeInMinutes:
                this.startTime = TimeSpan.FromMinutes(reader.ReadElementValue <int>());
                return(true);

            case XmlElementNames.EndTimeInMinutes:
                this.endTime = TimeSpan.FromMinutes(reader.ReadElementValue <int>());
                return(true);

            default:
                return(false);
            }
        }
Пример #17
0
        /// <summary>
        /// Load from xml
        /// </summary>
        /// <param name="reader">The reader</param>
        /// <returns>Non indexable item details result object</returns>
        internal static NonIndexableItemDetailsResult LoadFromXml(EwsServiceXmlReader reader)
        {
            NonIndexableItemDetailsResult nonIndexableItemDetailsResult = new NonIndexableItemDetailsResult();

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

            do
            {
                reader.Read();

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

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

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

            return(nonIndexableItemDetailsResult);
        }
Пример #18
0
        /// <summary>
        /// Tries to read element from XML.
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <returns>True if element was read.</returns>
        internal override bool TryReadElementFromXml(EwsServiceXmlReader reader)
        {
            switch (reader.LocalName)
            {
            case XmlElementNames.FlagStatus:
                this.flagStatus = reader.ReadElementValue <ItemFlagStatus>();
                return(true);

            case XmlElementNames.StartDate:
                this.startDate = reader.ReadElementValueAsDateTime().Value;
                return(true);

            case XmlElementNames.DueDate:
                this.dueDate = reader.ReadElementValueAsDateTime().Value;
                return(true);

            case XmlElementNames.CompleteDate:
                this.completeDate = reader.ReadElementValueAsDateTime().Value;
                return(true);

            default:
                return(false);
            }
        }
        /// <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);
        }
Пример #20
0
        /// <summary>
        /// Tries to read an 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.PhoneCallState:
                this.state = reader.ReadElementValue <PhoneCallState>();
                return(true);

            case XmlElementNames.ConnectionFailureCause:
                this.connectionFailureCause = reader.ReadElementValue <ConnectionFailureCause>();
                return(true);

            case XmlElementNames.SIPResponseText:
                this.sipResponseText = reader.ReadElementValue();
                return(true);

            case XmlElementNames.SIPResponseCode:
                this.sipResponseCode = reader.ReadElementValue <int>();
                return(true);

            default:
                return(false);
            }
        }
        /// <summary>
        /// Parses the response.
        /// See O15:324151 on why we need to override ParseResponse here instead of calling the one in MultiResponseServiceRequest.cs
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <returns>Service response collection.</returns>
        internal override object ParseResponse(EwsServiceXmlReader reader)
        {
            ServiceResponseCollection <SearchMailboxesResponse> serviceResponses = new ServiceResponseCollection <SearchMailboxesResponse>();

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

            while (true)
            {
                // Read ahead to see if we've reached the end of the response messages early.
                reader.Read();
                if (reader.IsEndElement(XmlNamespace.Messages, XmlElementNames.ResponseMessages))
                {
                    break;
                }

                SearchMailboxesResponse response = new SearchMailboxesResponse();
                response.LoadFromXml(reader, this.GetResponseMessageXmlElementName());
                serviceResponses.Add(response);
            }

            reader.ReadEndElementIfNecessary(XmlNamespace.Messages, XmlElementNames.ResponseMessages);

            return(serviceResponses);
        }
Пример #22
0
        /// <summary>
        /// Tries to read element from XML.
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <returns>True if element was read.</returns>
        internal override bool TryReadElementFromXml(EwsServiceXmlReader reader)
        {
            switch (reader.LocalName)
            {
            case XmlElementNames.SID:
                this.sID = reader.ReadValue();
                return(true);

            case XmlElementNames.PrimarySmtpAddress:
                this.primarySmtpAddress = reader.ReadValue();
                return(true);

            case XmlElementNames.DisplayName:
                this.displayName = reader.ReadValue();
                return(true);

            case XmlElementNames.DistinguishedUser:
                this.standardUser = reader.ReadValue <StandardUser>();
                return(true);

            default:
                return(false);
            }
        }
Пример #23
0
        /// <summary>
        /// Tries to read element from XML.
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <returns>True if element was read.</returns>
        internal override bool TryReadElementFromXml(EwsServiceXmlReader reader)
        {
            switch (reader.LocalName)
            {
            case XmlElementNames.IsUndecidedApprovalRequest:
                this.isUndecidedApprovalRequest = reader.ReadElementValue <bool>();
                return(true);

            case XmlElementNames.ApprovalDecision:
                this.approvalDecision = reader.ReadElementValue <int>();
                return(true);

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

            case XmlElementNames.ApprovalDecisionTime:
                this.approvalDecisionTime = reader.ReadElementValueAsDateTime().Value;
                return(true);

            default:
                return(false);
            }
        }
Пример #24
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.MeetingTime:
                this.meetingTime = reader.ReadElementValueAsUnbiasedDateTimeScopedToServiceTimeZone();
                return(true);

            case XmlElementNames.IsWorkTime:
                this.isWorkTime = reader.ReadElementValue <bool>();
                return(true);

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

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

                        if (reader.IsStartElement())
                        {
                            Conflict conflict = null;

                            switch (reader.LocalName)
                            {
                            case XmlElementNames.UnknownAttendeeConflictData:
                                conflict = new Conflict(ConflictType.UnknownAttendeeConflict);
                                break;

                            case XmlElementNames.TooBigGroupAttendeeConflictData:
                                conflict = new Conflict(ConflictType.GroupTooBigConflict);
                                break;

                            case XmlElementNames.IndividualAttendeeConflictData:
                                conflict = new Conflict(ConflictType.IndividualAttendeeConflict);
                                break;

                            case XmlElementNames.GroupAttendeeConflictData:
                                conflict = new Conflict(ConflictType.GroupConflict);
                                break;

                            default:
                                EwsUtilities.Assert(
                                    false,
                                    "TimeSuggestion.TryReadElementFromXml",
                                    string.Format("The {0} element name does not map to any AttendeeConflict descendant.", reader.LocalName));

                                // The following line to please the compiler
                                break;
                            }

                            conflict.LoadFromXml(reader, reader.LocalName);

                            this.conflicts.Add(conflict);
                        }
                    }while (!reader.IsEndElement(XmlNamespace.Types, XmlElementNames.AttendeeConflictDataArray));
                }

                return(true);

            default:
                return(false);
            }
        }
Пример #25
0
        /// <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>
        /// 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();
            }
        }
Пример #27
0
        /// <summary>
        /// Tries to read element from XML.
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <returns>True if element was read.</returns>
        internal override bool TryReadElementFromXml(EwsServiceXmlReader reader)
        {
            switch (reader.LocalName)
            {
            case XmlElementNames.AssignCategories:
                this.assignCategories.LoadFromXml(reader, reader.LocalName);
                return(true);

            case XmlElementNames.CopyToFolder:
                reader.ReadStartElement(XmlNamespace.NotSpecified, XmlElementNames.FolderId);
                this.copyToFolder = new FolderId();
                this.copyToFolder.LoadFromXml(reader, XmlElementNames.FolderId);
                reader.ReadEndElement(XmlNamespace.NotSpecified, XmlElementNames.CopyToFolder);
                return(true);

            case XmlElementNames.Delete:
                this.delete = reader.ReadElementValue <bool>();
                return(true);

            case XmlElementNames.ForwardAsAttachmentToRecipients:
                this.forwardAsAttachmentToRecipients.LoadFromXml(reader, reader.LocalName);
                return(true);

            case XmlElementNames.ForwardToRecipients:
                this.forwardToRecipients.LoadFromXml(reader, reader.LocalName);
                return(true);

            case XmlElementNames.MarkImportance:
                this.markImportance = reader.ReadElementValue <Importance>();
                return(true);

            case XmlElementNames.MarkAsRead:
                this.markAsRead = reader.ReadElementValue <bool>();
                return(true);

            case XmlElementNames.MoveToFolder:
                reader.ReadStartElement(XmlNamespace.NotSpecified, XmlElementNames.FolderId);
                this.moveToFolder = new FolderId();
                this.moveToFolder.LoadFromXml(reader, XmlElementNames.FolderId);
                reader.ReadEndElement(XmlNamespace.NotSpecified, XmlElementNames.MoveToFolder);
                return(true);

            case XmlElementNames.PermanentDelete:
                this.permanentDelete = reader.ReadElementValue <bool>();
                return(true);

            case XmlElementNames.RedirectToRecipients:
                this.redirectToRecipients.LoadFromXml(reader, reader.LocalName);
                return(true);

            case XmlElementNames.SendSMSAlertToRecipients:
                EmailAddressCollection smsRecipientCollection = new EmailAddressCollection(XmlElementNames.Address);
                smsRecipientCollection.LoadFromXml(reader, reader.LocalName);
                this.sendSMSAlertToRecipients = ConvertSMSRecipientsFromEmailAddressCollectionToMobilePhoneCollection(smsRecipientCollection);
                return(true);

            case XmlElementNames.ServerReplyWithMessage:
                this.serverReplyWithMessage = new ItemId();
                this.serverReplyWithMessage.LoadFromXml(reader, reader.LocalName);
                return(true);

            case XmlElementNames.StopProcessingRules:
                this.stopProcessingRules = reader.ReadElementValue <bool>();
                return(true);

            default:
                return(false);
            }
        }
Пример #28
0
 /// <summary>
 /// Reads text value from XML.
 /// </summary>
 /// <param name="reader">The reader.</param>
 internal override void ReadTextValueFromXml(EwsServiceXmlReader reader)
 {
     this.content = System.Convert.FromBase64String(reader.ReadValue());
 }
Пример #29
0
 /// <summary>
 /// Reads attributes from XML.
 /// This should always be UTF-8 for MimeContentUTF8
 /// </summary>
 /// <param name="reader">The reader.</param>
 internal override void ReadAttributesFromXml(EwsServiceXmlReader reader)
 {
     this.characterSet = reader.ReadAttributeValue <string>(XmlAttributeNames.CharacterSet);
 }
 /// <summary>
 /// Loads from XML.
 /// </summary>
 /// <param name="reader">The reader.</param>
 internal void LoadFromXml(EwsServiceXmlReader reader)
 {
     this.LoadFromXml(reader, this.GetXmlElementName());
 }