/// <summary>
        /// Loads from XML.
        /// </summary>
        /// <param name="reader">The reader.</param>
        internal void LoadFromXml(EwsServiceXmlReader reader)
        {
            reader.ReadStartElement(XmlNamespace.Types, XmlElementNames.Resolution);

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

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

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

                reader.ReadEndElement(XmlNamespace.Types, XmlElementNames.Resolution);
            }
            else
            {
                reader.EnsureCurrentNodeIsEndElement(XmlNamespace.Types, XmlElementNames.Resolution);
            }
        }
Example #2
0
    /// <summary>
    /// Loads an entry, consisting of a key value pair, into this dictionary from the specified reader.
    /// </summary>
    /// <param name="reader">The reader.</param>
    /* private */ void LoadEntry(EwsServiceXmlReader reader)
    {
        EwsUtilities.Assert(
            reader != null,
            "UserConfigurationDictionary.LoadEntry",
            "reader is null");

        object key;
        object value = null;

        // Position at DictionaryKey
        reader.ReadStartElement(this.Namespace, XmlElementNames.DictionaryKey);

        key = this.GetDictionaryObject(reader);

        // Position at DictionaryValue
        reader.ReadStartElement(this.Namespace, XmlElementNames.DictionaryValue);

        String nil      = reader.ReadAttributeValue(XmlNamespace.XmlSchemaInstance, XmlAttributeNames.Nil);
        bool   hasValue = (nil == null) || (!Convert.ToBoolean(nil));

        if (hasValue)
        {
            value = this.GetDictionaryObject(reader);
        }

        this.dictionary.Add(key, value);
    }
    object ParseResponse(EwsServiceXmlReader reader)
    {
        GetUserAvailabilityResults serviceResponse = new GetUserAvailabilityResults();

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

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

            do
            {
                reader.Read();

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

                    freeBusyResponse.LoadFromXml(reader, XmlElementNames.ResponseMessage);

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

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

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

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

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

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

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

        return(serviceResponse);
    }
        /// <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>
        /// Read Photo results from XML.
        /// </summary>
        /// <param name="reader">The reader.</param>
        internal override void ReadElementsFromXml(EwsServiceXmlReader reader)
        {
            bool hasChanged = reader.ReadElementValue<bool>(XmlNamespace.Messages, XmlElementNames.HasChanged);

            reader.ReadStartElement(XmlNamespace.Messages, XmlElementNames.PictureData);
            byte[] photoData = reader.ReadBase64ElementValue();

            // We only get a content type if we get a photo
            if (photoData.Length > 0)
            {
                this.Results.Photo = photoData;
                this.Results.ContentType = reader.ReadElementValue(XmlNamespace.Messages, XmlElementNames.ContentType);
            }

            if (hasChanged)
            {
                if (this.Results.Photo.Length == 0)
                {
                    this.Results.Status = GetUserPhotoStatus.PhotoOrUserNotFound;
                }
                else
                {
                    this.Results.Status = GetUserPhotoStatus.PhotoReturned;
                }
            }
            else
            {
                this.Results.Status = GetUserPhotoStatus.PhotoUnchanged;
            }
        }
        /// <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);
            }
        }
        /// <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);
            }
        }
    void ReadElementsFromXml(EwsServiceXmlReader reader)
    {
        this.Conversation = new ConversationResponse(this.propertySet);

        reader.ReadStartElement(XmlNamespace.Messages, XmlElementNames.Conversation);
        this.Conversation.LoadFromXml(reader, XmlNamespace.Messages, XmlElementNames.Conversation);
    }
Example #9
0
    void ReadElementsFromXml(EwsServiceXmlReader reader)
    {
        this.ClientExtensions.Clear();
        base.ReadElementsFromXml(reader);

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

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

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

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

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

        reader.Read();
        if (reader.IsStartElement(XmlNamespace.Messages, XmlElementNames.ClientExtensionRawMasterTableXml))
        {
            this.rawMasterTableXml = reader.ReadElementValue();
        }
    }
    void ReadElementsFromXml(EwsServiceXmlReader reader)
    {
        bool hasChanged = reader.ReadElementValue <bool>(XmlNamespace.Messages, XmlElementNames.HasChanged);

        reader.ReadStartElement(XmlNamespace.Messages, XmlElementNames.PictureData);
        Uint8List photoData = reader.ReadBase64ElementValue();

        // We only get a content type if we get a photo
        if (photoData.Length > 0)
        {
            this.Results.Photo       = photoData;
            this.Results.ContentType = reader.ReadElementValue(XmlNamespace.Messages, XmlElementNames.ContentType);
        }

        if (hasChanged)
        {
            if (this.Results.Photo.Length == 0)
            {
                this.Results.Status = GetUserPhotoStatus.PhotoOrUserNotFound;
            }
            else
            {
                this.Results.Status = GetUserPhotoStatus.PhotoReturned;
            }
        }
        else
        {
            this.Results.Status = GetUserPhotoStatus.PhotoUnchanged;
        }
    }
Example #11
0
    void ReadElementsFromXml(EwsServiceXmlReader reader)
    {
        this.searchableMailboxes.Clear();

        base.ReadElementsFromXml(reader);

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

        reader.Read();
        if (reader.IsStartElement(XmlNamespace.Messages, XmlElementNames.FailedMailboxes))
        {
            this.FailedMailboxes = FailedSearchMailbox.LoadFailedMailboxesXml(XmlNamespace.Messages, reader);
        }
    }
        /// <summary>
        /// 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);
            }
        }
        /// <summary>
        /// Read Conversations from XML.
        /// </summary>
        /// <param name="reader">The reader.</param>
        internal override void ReadElementsFromXml(EwsServiceXmlReader reader)
        {
            this.Conversation = new ConversationResponse(this.propertySet);

            reader.ReadStartElement(XmlNamespace.Messages, XmlElementNames.Conversation);
            this.Conversation.LoadFromXml(reader, XmlNamespace.Messages, XmlElementNames.Conversation);
        }
Example #14
0
    void ReadElementsFromXml(EwsServiceXmlReader reader)
    {
        this.Rooms.Clear();
        base.ReadElementsFromXml(reader);

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

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

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

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

            reader.EnsureCurrentNodeIsEndElement(XmlNamespace.Messages, XmlElementNames.Rooms);
        }
    }
Example #15
0
        /// <summary>
        /// Load from XML.
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <param name="propertyBag">The property bag.</param>
        internal override void InternalLoadFromXml(EwsServiceXmlReader reader, PropertyBag propertyBag)
        {
            reader.ReadStartElement(XmlNamespace.Types, this.containedXmlElementName);

            base.InternalLoadFromXml(reader, propertyBag);

            reader.ReadEndElementIfNecessary(XmlNamespace.Types, this.containedXmlElementName);
        }
Example #16
0
    /// <summary>
    /// Loads from XML.
    /// </summary>
    /// <param name="reader">The reader.</param>
    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));
    }
        /// <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>
        /// Reads response elements from XML.
        /// </summary>
        /// <param name="reader">The reader.</param>
        internal override void ReadElementsFromXml(EwsServiceXmlReader reader)
        {
            reader.ReadStartElement(XmlNamespace.Messages, XmlElementNames.RootFolder);

            this.results.TotalCount = reader.ReadAttributeValue<int>(XmlAttributeNames.TotalItemsInView);
            this.results.MoreAvailable = !reader.ReadAttributeValue<bool>(XmlAttributeNames.IncludesLastItemInRange);

            // Ignore IndexedPagingOffset attribute if MoreAvailable is false.
            this.results.NextPageOffset = results.MoreAvailable ? reader.ReadNullableAttributeValue<int>(XmlAttributeNames.IndexedPagingOffset) : null;

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

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

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

                            this.results.Folders.Add(folder);
                        }
                    }
                }
                while (!reader.IsEndElement(XmlNamespace.Types, XmlElementNames.Folders));
            }

            reader.ReadEndElement(XmlNamespace.Messages, XmlElementNames.RootFolder);
        }
    void ReadElementsFromXml(EwsServiceXmlReader reader)
    {
        base.ReadElementsFromXml(reader);

        reader.ReadStartElement(XmlNamespace.Messages, XmlElementNames.Token);
        this.Id         = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.Id);
        this.TokenType  = (ClientAccessTokenType)Enum.Parse(typeof(ClientAccessTokenType), reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.TokenType));
        this.TokenValue = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.TokenValue);
        this.TTL        = int.Parse(reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.TTL));
        reader.ReadEndElementIfNecessary(XmlNamespace.Messages, XmlElementNames.Token);
    }
        /// <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.Token);
            this.Id = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.Id);
            this.TokenType = (ClientAccessTokenType)Enum.Parse(typeof(ClientAccessTokenType), reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.TokenType));
            this.TokenValue = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.TokenValue);
            this.TTL = int.Parse(reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.TTL));
            reader.ReadEndElementIfNecessary(XmlNamespace.Messages, XmlElementNames.Token);
        }
        /// <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>
    void LoadFromXml(EwsServiceXmlReader reader)
    {
        reader.ReadStartElement(XmlNamespace.Messages, XmlElementNames.DLExpansion);
        if (!reader.IsEmptyElement)
        {
            int totalItemsInView = reader.ReadAttributeValue <int>(XmlAttributeNames.TotalItemsInView);
            this.includesAllMembers = reader.ReadAttributeValue <bool>(XmlAttributeNames.IncludesLastItemInRange);

            for (int i = 0; i < totalItemsInView; i++)
            {
                EmailAddress emailAddress = new EmailAddress();

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

                this.members.Add(emailAddress);
            }

            reader.ReadEndElement(XmlNamespace.Messages, XmlElementNames.DLExpansion);
        }
    }
        /// <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));
        }
Example #25
0
    /// <summary>
    /// Extracts the dictionary object (key or entry value) type from the specified reader.
    /// </summary>
    /// <param name="reader">The reader.</param>
    /// <returns>Dictionary object type.</returns>
    /* private */ UserConfigurationDictionaryObjectType GetObjectType(EwsServiceXmlReader reader)
    {
        EwsUtilities.Assert(
            reader != null,
            "UserConfigurationDictionary.LoadFromXml",
            "reader is null");

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

        String type = reader.ReadElementValue();

        return(GetObjectType(type));
    }
Example #26
0
    void ReadElementsFromXml(EwsServiceXmlReader reader)
    {
        reader.ReadStartElement(XmlNamespace.Messages, XmlElementNames.ReturnValue);


        {
            this.ReturnValue = new SafeXmlDocument();
            this.ReturnValue.Load(returnValueReader);
        }

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

            using (XmlReader returnValueReader = reader.GetXmlReaderForNode())
            {
                this.ReturnValue = new SafeXmlDocument();
                this.ReturnValue.Load(returnValueReader);
            }

            reader.SkipCurrentElement();
            reader.ReadEndElementIfNecessary(XmlNamespace.Messages, XmlElementNames.ReturnValue);
        }
        /// <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.RootItemId);

            string changeKey = reader.ReadAttributeValue(XmlAttributeNames.RootItemChangeKey);
            if (!string.IsNullOrEmpty(changeKey) && this.attachment.Owner != null)
            {
                this.attachment.Owner.RootItemId.ChangeKey = changeKey;
            }

            reader.ReadEndElementIfNecessary(XmlNamespace.Messages, XmlElementNames.RootItemId);
        }
    /// <summary>
    /// Load from xml
    /// </summary>
    /// <param name="reader">The reader</param>
    /// <returns>Mailbox hold object</returns>
    static MailboxHoldResult LoadFromXml(EwsServiceXmlReader reader)
    {
        List <MailboxHoldStatus> statuses = new List <MailboxHoldStatus>();

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

        MailboxHoldResult holdResult = new MailboxHoldResult();

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

        // the query could be empty means there won't be Query element, hence needs to read and check
        // if the next element is not Query, then it means already read MailboxHoldStatuses element
        reader.Read();
        holdResult.Query = "";
        if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.Query))
        {
            holdResult.Query = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.Query);
            reader.ReadStartElement(XmlNamespace.Types, XmlElementNames.MailboxHoldStatuses);
        }

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

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

        return(holdResult);
    }
        /// <summary>
        /// Reads response elements from XML.
        /// </summary>
        /// <param name="reader">The reader.</param>
        internal override void ReadElementsFromXml(EwsServiceXmlReader reader)
        {
            if (this.readDelegateUser)
            {
                if (this.delegateUser == null)
                {
                    this.delegateUser = new DelegateUser();
                }

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

                this.delegateUser.LoadFromXml(
                    reader,
                    XmlNamespace.Messages,
                    reader.LocalName);
            }
        }
Example #31
0
        /// <summary>
        /// Reads response elements from XML.
        /// </summary>
        /// <param name="reader">The reader.</param>
        internal override void ReadElementsFromXml(EwsServiceXmlReader reader)
        {
            if (this.readDelegateUser)
            {
                if (this.delegateUser == null)
                {
                    this.delegateUser = new DelegateUser();
                }

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

                this.delegateUser.LoadFromXml(
                    reader,
                    XmlNamespace.Messages,
                    reader.LocalName);
            }
        }
Example #32
0
    /// <summary>
    /// Extracts a dictionary object (key or entry value) as a String list from the
    /// specified reader.
    /// </summary>
    /// <param name="reader">The reader.</param>
    /// <param name="type">The object type.</param>
    /// <returns>String list representing a dictionary object.</returns>
    /* private */ List <string> GetObjectValue(EwsServiceXmlReader reader, UserConfigurationDictionaryObjectType type)
    {
        EwsUtilities.Assert(
            reader != null,
            "UserConfigurationDictionary.LoadFromXml",
            "reader is null");

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

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

        do
        {
            String value = null;

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

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

            values.Add(value);

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

        return(values);
    }
Example #33
0
    /// <summary>
    /// Loads the suggested days from XML.
    /// </summary>
    /// <param name="reader">The reader.</param>
    void LoadSuggestedDaysFromXml(EwsServiceXmlReader reader)
    {
        reader.ReadStartElement(XmlNamespace.Messages, XmlElementNames.SuggestionDayResultArray);

        do
        {
            reader.Read();

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

                daySuggestion.LoadFromXml(reader, reader.LocalName);

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

            do
            {
                reader.Read();

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

                    daySuggestion.LoadFromXml(reader, reader.LocalName);

                    this.daySuggestions.Add(daySuggestion);
                }
            }
            while (!reader.IsEndElement(XmlNamespace.Messages, XmlElementNames.SuggestionDayResultArray));
        }
    void ReadElementsFromXml(EwsServiceXmlReader reader)
    {
        base.ReadElementsFromXml(reader);

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

        String alternateIdClass = reader.ReadAttributeValue(XmlNamespace.XmlSchemaInstance, XmlAttributeNames.Type);

        int aliasSeparatorIndex = alternateIdClass.IndexOf(':');

        if (aliasSeparatorIndex > -1)
        {
            alternateIdClass = alternateIdClass.Substring(aliasSeparatorIndex + 1);
        }

        // Alternate Id classes are responsible fro reading the AlternateId end element when necessary
        switch (alternateIdClass)
        {
        case AlternateId.SchemaTypeName:
            this.convertedId = new AlternateId();
            break;

        case AlternatePublicFolderId.SchemaTypeName:
            this.convertedId = new AlternatePublicFolderId();
            break;

        case AlternatePublicFolderItemId.SchemaTypeName:
            this.convertedId = new AlternatePublicFolderItemId();
            break;

        default:
            EwsUtilities.Assert(
                false,
                "ConvertIdResponse.ReadElementsFromXml",
                string.Format("Unknown alternate Id class: {0}", alternateIdClass));
            break;
        }

        this.convertedId.LoadAttributesFromXml(reader);

        reader.ReadEndElementIfNecessary(XmlNamespace.Messages, XmlElementNames.AlternateId);
    }
    object ParseResponse(EwsServiceXmlReader reader)
    {
        GetUserOofSettingsResponse serviceResponse = new GetUserOofSettingsResponse();

        serviceResponse.LoadFromXml(reader, XmlElementNames.ResponseMessage);

        if (serviceResponse.ErrorCode == ServiceError.NoError)
        {
            reader.ReadStartElement(XmlNamespace.Types, XmlElementNames.OofSettings);

            serviceResponse.OofSettings = new OofSettings();
            serviceResponse.OofSettings.LoadFromXml(reader, reader.LocalName);

            serviceResponse.OofSettings.AllowExternalOof = reader.ReadElementValue <OofExternalAudience>(
                XmlNamespace.Messages,
                XmlElementNames.AllowExternalOof);
        }

        return(serviceResponse);
    }
Example #37
0
    void ReadElementsFromXml(EwsServiceXmlReader reader)
    {
        this.retentionPolicyTags.Clear();

        base.ReadElementsFromXml(reader);

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

        base.ReadElementsFromXml(reader);

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

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

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

            base.ReadElementsFromXml(reader);

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

            base.ReadElementsFromXml(reader);

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

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

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

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

            reader.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;
                }
            }
        }
Example #45
0
    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.ReadStartElement(XmlNamespace.Messages, XmlElementNames.AlternateId);

            string alternateIdClass = reader.ReadAttributeValue(XmlNamespace.XmlSchemaInstance, XmlAttributeNames.Type);

            int aliasSeparatorIndex = alternateIdClass.IndexOf(':');

            if (aliasSeparatorIndex > -1)
            {
                alternateIdClass = alternateIdClass.Substring(aliasSeparatorIndex + 1);
            }

            // Alternate Id classes are responsible fro reading the AlternateId end element when necessary
            switch (alternateIdClass)
            {
                case AlternateId.SchemaTypeName:
                    this.convertedId = new AlternateId();
                    break;
                case AlternatePublicFolderId.SchemaTypeName:
                    this.convertedId = new AlternatePublicFolderId();
                    break;
                case AlternatePublicFolderItemId.SchemaTypeName:
                    this.convertedId = new AlternatePublicFolderItemId();
                    break;
                default:
                    EwsUtilities.Assert(
                        false,
                        "ConvertIdResponse.ReadElementsFromXml",
                        string.Format("Unknown alternate Id class: {0}", alternateIdClass));
                    break;
            }

            this.convertedId.LoadAttributesFromXml(reader);

            reader.ReadEndElementIfNecessary(XmlNamespace.Messages, XmlElementNames.AlternateId);
        }
        /// <summary>
        /// Read Conversations from XML.
        /// </summary>
        /// <param name="reader">The reader.</param>
        internal override void ReadElementsFromXml(EwsServiceXmlReader reader)
        {
            this.groupsSets.Clear();
            base.ReadElementsFromXml(reader);

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

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

                // Skip end element GroupsSets
                reader.EnsureCurrentNodeIsEndElement(XmlNamespace.NotSpecified, XmlElementNames.GroupsSets);
                reader.Read();
            }
        }
        /// <summary>
        /// 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;
        }
        /// <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));
            }
        }
    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));
        }
    }
    /// <summary>
    /// Load from xml
    /// </summary>
    /// <param name="reader">The reader</param>
    /// <returns>Non indexable item details result object</returns>
    static NonIndexableItemDetailsResult LoadFromXml(EwsServiceXmlReader reader)
    {
        NonIndexableItemDetailsResult nonIndexableItemDetailsResult = new NonIndexableItemDetailsResult();

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

        do
        {
            reader.Read();

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

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

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

        return(nonIndexableItemDetailsResult);
    }
    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);
    }
        /// <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));
            }
        }
Example #54
0
    /// <summary>
    /// Loads the free busy view from XML.
    /// </summary>
    /// <param name="reader">The reader.</param>
    /// <param name="viewType">Type of free/busy view.</param>
    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 <String>();

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

                    break;

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

                        // Sometimes Exchange Online returns blank CalendarEventArray tag like bellow.
                        // <CalendarEventArray xmlns="http://schemas.microsoft.com/exchange/services/2006/types" />
                        // So we have to check the end of CalendarEventArray tag.
                        if (reader.LocalName == XmlElementNames.FreeBusyView)
                        {
                            // There is no the end tag of CalendarEventArray, but the reader is reading the end tag of FreeBusyView.
                            break;
                        }
                        else if (reader.LocalName == XmlElementNames.WorkingHours)
                        {
                            // There is no the end tag of CalendarEventArray, but the reader is reading the start tag of WorkingHours.
                            goto case XmlElementNames.WorkingHours;
                        }

                        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));
    }
    void ReadElementsFromXml(EwsServiceXmlReader reader)
    {
        EwsUtilities.Assert(
            this.Results.Conversations != null,
            "FindConversationResponse.ReadElementsFromXml",
            "conversations is null.");

        EwsUtilities.Assert(
            this.Results.HighlightTerms != null,
            "FindConversationResponse.ReadElementsFromXml",
            "highlightTerms is null.");

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

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

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

                        this.Results.Conversations.Add(item);
                    }
                }
            }while (!reader.IsEndElement(XmlNamespace.Messages, XmlElementNames.Conversations));
        }

        reader.Read();

        if (reader.IsStartElement(XmlNamespace.Messages, XmlElementNames.HighlightTerms) &&
            !reader.IsEmptyElement)
        {
            do
            {
                reader.Read();

                if (reader.NodeType == XmlNodeType.Element)
                {
                    HighlightTerm term = new HighlightTerm();

                    term.LoadFromXml(
                        reader,
                        XmlNamespace.Types,
                        XmlElementNames.HighlightTerm);

                    this.Results.HighlightTerms.Add(term);
                }
            }while (!reader.IsEndElement(XmlNamespace.Messages, XmlElementNames.HighlightTerms));
        }

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

            reader.Read();
        }

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

            reader.Read();
        }
    }
    void ReadElementsFromXml(EwsServiceXmlReader reader)
    {
        EwsUtilities.Assert(
            this.Results.Personas != null,
            "FindPeopleResponse.ReadElementsFromXml",
            "Personas is null.");

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

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

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

        reader.Read();

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

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

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

        if (reader.IsStartElement(XmlNamespace.Messages, XmlElementNames.FindPeopleTransactionId) && !reader.IsEmptyElement)
        {
            this.TransactionId = reader.ReadElementValue <string>();
            reader.Read();
        }

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

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

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

            do
            {
                string value = null;

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

                values.Add(value);

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

            return values;
        }
 /// <summary>
 /// 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;
     }
 }
        /// <summary>
        /// Parses the response.
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <returns>Response object.</returns>
        internal override object ParseResponse(EwsServiceXmlReader reader)
        {
            GetUserOofSettingsResponse serviceResponse = new GetUserOofSettingsResponse();

            serviceResponse.LoadFromXml(reader, XmlElementNames.ResponseMessage);

            if (serviceResponse.ErrorCode == ServiceError.NoError)
            {
                reader.ReadStartElement(XmlNamespace.Types, XmlElementNames.OofSettings);

                serviceResponse.OofSettings = new OofSettings();
                serviceResponse.OofSettings.LoadFromXml(reader, reader.LocalName);

                serviceResponse.OofSettings.AllowExternalOof = reader.ReadElementValue<OofExternalAudience>(
                    XmlNamespace.Messages,
                    XmlElementNames.AllowExternalOof);
            }

            return serviceResponse;
        }
        /// <summary>
        /// Extracts the dictionary object (key or entry value) type from the specified reader.
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <returns>Dictionary object type.</returns>
        private UserConfigurationDictionaryObjectType GetObjectType(EwsServiceXmlReader reader)
        {
            EwsUtilities.Assert(
                reader != null,
                "UserConfigurationDictionary.LoadFromXml",
                "reader is null");

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

            string type = reader.ReadElementValue();

            return GetObjectType(type);
        }