Esempio n. 1
0
        /// <summary>
        /// Load from XML.
        /// </summary>
        /// <param name="reader">The reader.</param>
        internal override void InternalLoadFromXml(EwsServiceXmlReader reader)
        {
            base.InternalLoadFromXml(reader);

            this.itemId = new ItemId();
            this.itemId.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.oldItemId = new ItemId();
                this.oldItemId.LoadFromXml(reader, reader.LocalName);

                reader.Read();

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

            default:
                break;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Loads from XML.
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <param name="allowNoMoreElements">If true the function returns false rather than throw an exception
        /// if the last element has been read.</param>
        internal bool LoadFromXml(EwsServiceXmlReader reader, bool allowNoMoreElements)
        {
            reader.Read();
            if (allowNoMoreElements && reader.NodeType == System.Xml.XmlNodeType.EndElement)
            {
                return(false);
            }

            reader.EnsureCurrentNodeIsStartElement(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);
            }
            return(true);
        }
        /// <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));
                }
            }
        }
        /// <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);
            }
        }
Esempio n. 5
0
        /// <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>
        /// 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);
            }
        }
Esempio n. 7
0
        /// <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);
        }
Esempio n. 8
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.Periods:
                do
                {
                    reader.Read();

                    if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.Period))
                    {
                        TimeZonePeriod period = new TimeZonePeriod();
                        period.LoadFromXml(reader);

                        this.periods.Add(period.Id, period);
                    }
                }while (!reader.IsEndElement(XmlNamespace.Types, XmlElementNames.Periods));

                return(true);

            case XmlElementNames.TransitionsGroups:
                do
                {
                    reader.Read();

                    if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.TransitionsGroup))
                    {
                        TimeZoneTransitionGroup transitionGroup = new TimeZoneTransitionGroup(this);

                        transitionGroup.LoadFromXml(reader);

                        this.transitionGroups.Add(transitionGroup.Id, transitionGroup);
                    }
                }while (!reader.IsEndElement(XmlNamespace.Types, XmlElementNames.TransitionsGroups));

                return(true);

            case XmlElementNames.Transitions:
                do
                {
                    reader.Read();

                    if (reader.IsStartElement())
                    {
                        TimeZoneTransition transition = TimeZoneTransition.Create(this, reader.LocalName);

                        transition.LoadFromXml(reader);

                        this.transitions.Add(transition);
                    }
                }while (!reader.IsEndElement(XmlNamespace.Types, XmlElementNames.Transitions));

                return(true);

            default:
                return(false);
            }
        }
        /// <summary>
        /// Loads from XML.
        /// </summary>
        /// <param name="reader">The reader.</param>
        internal void LoadFromXml(EwsServiceXmlReader reader)
        {
            EwsUtilities.Assert(
                reader != null,
                "UserConfiguration.LoadFromXml",
                "reader is null");

            reader.ReadStartElement(XmlNamespace.Messages, XmlElementNames.UserConfiguration);
            reader.Read(); // Position at first property element

            do
            {
                if (reader.NodeType == XmlNodeType.Element)
                {
                    switch (reader.LocalName)
                    {
                    case XmlElementNames.UserConfigurationName:
                        string responseName = reader.ReadAttributeValue(XmlAttributeNames.Name);

                        EwsUtilities.Assert(
                            string.Compare(this.name, responseName, StringComparison.Ordinal) == 0,
                            "UserConfiguration.LoadFromXml",
                            "UserConfigurationName does not match: Expected: " + this.name + " Name in response: " + responseName);

                        reader.SkipCurrentElement();
                        break;

                    case XmlElementNames.ItemId:
                        this.itemId = new ItemId();
                        this.itemId.LoadFromXml(reader, XmlElementNames.ItemId);
                        break;

                    case XmlElementNames.Dictionary:
                        this.dictionary.LoadFromXml(reader, XmlElementNames.Dictionary);
                        break;

                    case XmlElementNames.XmlData:
                        this.xmlData = Convert.FromBase64String(reader.ReadElementValue());
                        break;

                    case XmlElementNames.BinaryData:
                        this.binaryData = Convert.FromBase64String(reader.ReadElementValue());
                        break;

                    default:
                        EwsUtilities.Assert(
                            false,
                            "UserConfiguration.LoadFromXml",
                            "Xml element not supported: " + reader.LocalName);
                        break;
                    }
                }

                // If XmlData was loaded, read is skipped because GetXmlData positions the reader at the next property.
                reader.Read();
            }while (!reader.IsEndElement(XmlNamespace.Messages, XmlElementNames.UserConfiguration));
        }
Esempio n. 10
0
        /// <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();
            }
        }
        /// <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));
        }
        /// <summary>
        /// Loads from XML.
        /// </summary>
        /// <param name="reader">The reader.</param>
        internal void LoadFromXml(EwsServiceXmlReader reader)
        {
            reader.ReadStartElement(XmlNamespace.Messages, XmlElementNames.Notification);

            do
            {
                NotificationGroup notifications = new NotificationGroup();
                notifications.SubscriptionId = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.SubscriptionId);
                notifications.Events         = new Collection <NotificationEvent>();

                lock (this)
                {
                    this.events.Add(notifications);
                }

                do
                {
                    reader.Read();

                    if (reader.IsStartElement())
                    {
                        string    eventElementName = reader.LocalName;
                        EventType eventType;

                        if (GetEventsResults.XmlElementNameToEventTypeMap.TryGetValue(eventElementName, out eventType))
                        {
                            if (eventType == EventType.Status)
                            {
                                // We don't need to return status events
                                reader.ReadEndElementIfNecessary(XmlNamespace.Types, eventElementName);
                            }
                            else
                            {
                                this.LoadNotificationEventFromXml(
                                    reader,
                                    eventElementName,
                                    eventType,
                                    notifications);
                            }
                        }
                        else
                        {
                            reader.SkipCurrentElement();
                        }
                    }
                }while (!reader.IsEndElement(XmlNamespace.Messages, XmlElementNames.Notification));

                reader.Read();
            }while (!reader.IsEndElement(XmlNamespace.Messages, XmlElementNames.Notifications));
        }
        /// <summary>
        /// Reads response elements from XML.
        /// </summary>
        /// <param name="reader">The reader.</param>
        internal override void ReadElementsFromXml(EwsServiceXmlReader reader)
        {
            this.Manifests.Clear();
            base.ReadElementsFromXml(reader);

            reader.Read(XmlNodeType.Element);

            // We can have a response from Exchange 2013 (first time this API was introduced)
            // or the newer response, starting in Exchange 2013 SP1, (X-EWS-TargetVersion: 2.5 or above)
            bool exchange2013Response;

            if (XmlElementNames.Manifests.Equals(reader.LocalName))
            {
                exchange2013Response = true;
            }
            else if (XmlElementNames.Apps.Equals(reader.LocalName))
            {
                exchange2013Response = false;
            }
            else
            {
                throw new ServiceXmlDeserializationException(
                          string.Format(
                              Strings.UnexpectedElement,
                              EwsUtilities.GetNamespacePrefix(XmlNamespace.Messages),
                              XmlElementNames.Manifests,
                              XmlNodeType.Element,
                              reader.LocalName,
                              reader.NodeType));
            }

            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();

                if (exchange2013Response)
                {
                    this.ReadFromExchange2013(reader);
                }
                else
                {
                    this.ReadFromExchange2013Sp1(reader);
                }
            }

            reader.EnsureCurrentNodeIsEndElement(XmlNamespace.Messages, exchange2013Response ? XmlElementNames.Manifests : XmlElementNames.Apps);
        }
Esempio n. 14
0
        /// <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);

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

                    if (reader.IsStartElement())
                    {
                        TEntry entry = this.CreateEntry(reader);

                        if (entry != null)
                        {
                            entry.LoadFromXml(reader, reader.LocalName);
                            this.InternalAdd(entry);
                        }
                        else
                        {
                            reader.SkipCurrentElement();
                        }
                    }
                }while (!reader.IsEndElement(XmlNamespace.Types, localElementName));
            }
        }
Esempio n. 15
0
        /// <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);
            }
        }
Esempio n. 16
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.Attachments);
            if (!reader.IsEmptyElement)
            {
                reader.Read(XmlNodeType.Element);

                if (this.attachment == null)
                {
                    if (string.Equals(reader.LocalName, XmlElementNames.FileAttachment, StringComparison.OrdinalIgnoreCase))
                    {
                        this.attachment = new FileAttachment(reader.Service);
                    }
                    else if (string.Equals(reader.LocalName, XmlElementNames.ItemAttachment, StringComparison.OrdinalIgnoreCase))
                    {
                        this.attachment = new ItemAttachment(reader.Service);
                    }
                }

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

                reader.ReadEndElement(XmlNamespace.Messages, XmlElementNames.Attachments);
            }
        }
Esempio n. 17
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.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>
        /// Read attribution blobs from XML
        /// </summary>
        /// <param name="reader">XML reader</param>
        /// <returns>Whether reading succeeded</returns>
        internal bool LoadAttributionsFromXml(EwsServiceXmlReader reader)
        {
            if (!reader.IsEmptyElement)
            {
                string localName = reader.LocalName;
                this.attributionList = new List <string>();

                do
                {
                    reader.Read();
                    if (reader.NodeType == XmlNodeType.Element &&
                        reader.LocalName == XmlElementNames.Attribution)
                    {
                        string s = reader.ReadElementValue();
                        if (!string.IsNullOrEmpty(s))
                        {
                            this.attributionList.Add(s);
                        }
                    }
                }while (!reader.IsEndElement(XmlNamespace.Types, localName));
                this.Attributions = this.attributionList.ToArray();
            }

            return(true);
        }
        /// <summary>
        /// Loads from XML
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <param name="xmlNamespace">The XML namespace.</param>
        /// <param name="xmlElementName">Name of the XML element.</param>
        /// <param name="readAction"></param>
        private void InternalLoadFromXml(
            EwsServiceXmlReader reader,
            XmlNamespace xmlNamespace,
            string xmlElementName,
            Func <EwsServiceXmlReader, bool> readAction)
        {
            reader.EnsureCurrentNodeIsStartElement(xmlNamespace, xmlElementName);

            this.ReadAttributesFromXml(reader);

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

                    switch (reader.NodeType)
                    {
                    case XmlNodeType.Element:
                        if (!readAction(reader))
                        {
                            reader.SkipCurrentElement();
                        }
                        break;

                    case XmlNodeType.Text:
                        this.ReadTextValueFromXml(reader);
                        break;
                    }
                }while (!reader.IsEndElement(xmlNamespace, xmlElementName));
            }
        }
        /// <summary>
        /// Load from xml.
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <returns>Retention policy tag object.</returns>
        internal static RetentionPolicyTag LoadFromXml(EwsServiceXmlReader reader)
        {
            reader.EnsureCurrentNodeIsStartElement(XmlNamespace.Types, XmlElementNames.RetentionPolicyTag);

            RetentionPolicyTag retentionPolicyTag = new RetentionPolicyTag();

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

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

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

            return(retentionPolicyTag);
        }
Esempio n. 21
0
        /// <summary>
        /// Loads from XML.
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <param name="xmlNamespace">The XML namespace.</param>
        /// <param name="localElementName">Name of the local element.</param>
        internal override void LoadFromXml(
            EwsServiceXmlReader reader,
            XmlNamespace xmlNamespace,
            string localElementName)
        {
            reader.EnsureCurrentNodeIsStartElement(xmlNamespace, localElementName);

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

                    if (reader.IsStartElement())
                    {
                        TComplexProperty complexProperty = this.CreateComplexProperty(reader.LocalName);

                        if (complexProperty != null)
                        {
                            complexProperty.LoadFromXml(reader, reader.LocalName);
                            this.InternalAdd(complexProperty, true);
                        }
                        else
                        {
                            reader.SkipCurrentElement();
                        }
                    }
                }while (!reader.IsEndElement(xmlNamespace, localElementName));
            }
        }
            /// <summary>
            /// Tries to read element from XML.
            /// </summary>
            /// <param name="reader">The reader.</param>
            /// <returns>True if element was read.</returns>
            internal override bool TryReadElementFromXml(EwsServiceXmlReader reader)
            {
                bool result = base.TryReadElementFromXml(reader);

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

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

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

                return(result);
            }
Esempio n. 23
0
        /// <summary>
        /// Loads from XML to update itself.
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <param name="xmlNamespace">The XML namespace.</param>
        /// <param name="xmlElementName">Name of the XML element.</param>
        internal override void UpdateFromXml(
            EwsServiceXmlReader reader,
            XmlNamespace xmlNamespace,
            string xmlElementName)
        {
            reader.EnsureCurrentNodeIsStartElement(xmlNamespace, xmlElementName);

            if (!reader.IsEmptyElement)
            {
                int index = 0;
                do
                {
                    reader.Read();

                    if (reader.IsStartElement())
                    {
                        TComplexProperty complexProperty       = this.CreateComplexProperty(reader.LocalName);
                        TComplexProperty actualComplexProperty = this[index++];

                        if (complexProperty == null || !complexProperty.GetType().IsInstanceOfType(actualComplexProperty))
                        {
                            throw new ServiceLocalException(Strings.PropertyTypeIncompatibleWhenUpdatingCollection);
                        }

                        actualComplexProperty.UpdateFromXml(reader, xmlNamespace, reader.LocalName);
                    }
                }while (!reader.IsEndElement(xmlNamespace, xmlElementName));
            }
        }
        /// <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();
            }
        }
Esempio n. 25
0
        /// <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);
            if (!reader.IsEmptyElement)
            {
                do
                {
                    reader.Read();

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

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

                            this.items.Add(item);
                        }
                    }
                }while (!reader.IsEndElement(XmlNamespace.Types, localElementName));
            }
        }
Esempio n. 26
0
        /// <summary>
        /// Tries to read element from XML.
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <returns>True if element was read.</returns>
        internal override bool TryReadElementFromXml(EwsServiceXmlReader reader)
        {
            do
            {
                reader.Read();
                InsightValue item = null;

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

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

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

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

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

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

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

            return(true);
        }
Esempio n. 27
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.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);
            }
        }
Esempio n. 28
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.Attachments);

            reader.Read(XmlNodeType.Element);
            this.attachment.LoadFromXml(reader, reader.LocalName);

            reader.ReadEndElement(XmlNamespace.Messages, XmlElementNames.Attachments);
        }
        /// <summary>
        /// Loads from XML.
        /// </summary>
        /// <param name="reader">The reader.</param>
        internal void LoadFromXml(EwsServiceXmlReader reader)
        {
            do
            {
                reader.Read();

                if (reader.NodeType == XmlNodeType.Element)
                {
                    this.TryReadElementFromXml(reader);
                }
            }while (!reader.IsEndElement(XmlNamespace.Types, XmlElementNames.PersonaPostalAddress));
        }
Esempio n. 30
0
        /// <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;
            }
        }