/// <summary>
        /// Reads attributes from XML.
        /// </summary>
        /// <param name="reader">The reader.</param>
        internal override void ReadAttributesFromXml(EwsServiceXmlReader reader)
        {
            this.bodyType = reader.ReadAttributeValue<BodyType>(XmlAttributeNames.BodyType);

            string attributeValue = reader.ReadAttributeValue(XmlAttributeNames.IsTruncated);
            if (!string.IsNullOrEmpty(attributeValue))
            {
                this.isTruncated = bool.Parse(attributeValue);
            }
        }
        /// <summary>
        /// Parse current element to extract server information
        /// </summary>
        /// <param name="reader">EwsServiceXmlReader</param>
        /// <returns>ExchangeServerInfo</returns>
        internal static ExchangeServerInfo Parse(EwsServiceXmlReader reader)
        {
            EwsUtilities.Assert(
                                reader.HasAttributes, 
                                "ExchangeServerVersion.Parse",
                                "Current element doesn't have attributes");

            ExchangeServerInfo info = new ExchangeServerInfo();
            info.MajorVersion = reader.ReadAttributeValue<int>("MajorVersion");
            info.MinorVersion = reader.ReadAttributeValue<int>("MinorVersion");
            info.MajorBuildNumber = reader.ReadAttributeValue<int>("MajorBuildNumber");
            info.MinorBuildNumber = reader.ReadAttributeValue<int>("MinorBuildNumber");
            info.VersionString = reader.ReadAttributeValue("Version");
            return info;
        }
        /// <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);
        }
 /// <summary>
 /// Tries to load from XML.
 /// </summary>
 /// <param name="reader">The reader.</param>
 /// <param name="propertyDefinition">The property definition.</param>
 /// <returns>True if property was loaded.</returns>
 internal static bool TryLoadFromXml(EwsServiceXmlReader reader, ref PropertyDefinitionBase propertyDefinition)
 {
     switch (reader.LocalName)
     {
         case XmlElementNames.FieldURI:
             propertyDefinition = ServiceObjectSchema.FindPropertyDefinition(reader.ReadAttributeValue(XmlAttributeNames.FieldURI));
             reader.SkipCurrentElement();
             return true;
         case XmlElementNames.IndexedFieldURI:
             propertyDefinition = new IndexedPropertyDefinition(
                 reader.ReadAttributeValue(XmlAttributeNames.FieldURI),
                 reader.ReadAttributeValue(XmlAttributeNames.FieldIndex));
             reader.SkipCurrentElement();
             return true;
         case XmlElementNames.ExtendedFieldURI:
             propertyDefinition = new ExtendedPropertyDefinition();
             (propertyDefinition as ExtendedPropertyDefinition).LoadFromXml(reader);
             return true;
         default:
             return false;
     }
 }
        /// <summary>
        /// Tries to read element from XML.
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <returns>True if element was read.</returns>
        internal override bool TryReadElementFromXml(EwsServiceXmlReader reader)
        {
            switch (reader.ReadAttributeValue("xsi:type"))
            {
                case XmlElementNames.StringInsightValue:
                    this.Item = new StringInsightValue();
                    this.Item.LoadFromXml(reader, reader.LocalName);
                    break;
                case XmlElementNames.ProfileInsightValue:
                    this.Item = new ProfileInsightValue();
                    this.Item.LoadFromXml(reader, reader.LocalName);
                    break;
                case XmlElementNames.JobInsightValue:
                    this.Item = new JobInsightValue();
                    this.Item.LoadFromXml(reader, reader.LocalName);
                    break;
                case XmlElementNames.UserProfilePicture:
                    this.Item = new UserProfilePicture();
                    this.Item.LoadFromXml(reader, reader.LocalName);
                    break;
                case XmlElementNames.EducationInsightValue:
                    this.Item = new EducationInsightValue();
                    this.Item.LoadFromXml(reader, reader.LocalName);
                    break;
                case XmlElementNames.SkillInsightValue:
                    this.Item = new SkillInsightValue();
                    this.Item.LoadFromXml(reader, reader.LocalName);
                    break;
                case XmlElementNames.DelveDocument:
                    this.Item = new DelveDocument();
                    this.Item.LoadFromXml(reader, reader.LocalName);
                    break;
                case XmlElementNames.CompanyInsightValue:
                    this.Item = new CompanyInsightValue();
                    this.Item.LoadFromXml(reader, reader.LocalName);
                    break;
                case XmlElementNames.ComputedInsightValue:
                    this.Item = new ComputedInsightValue();
                    this.Item.LoadFromXml(reader, reader.LocalName);
                    break;
                case XmlElementNames.OutOfOfficeInsightValue:
                    this.Item = new OutOfOfficeInsightValue();
                    this.Item.LoadFromXml(reader, reader.LocalName);
                    break;
                default:
                    return false;
            }

            return true;
        }
        /// <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>
        /// 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>
        /// 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)
        {
            while (true)
            {
                switch (reader.LocalName)
                {
                    case XmlElementNames.InsightType:
                        this.InsightType = reader.ReadElementValue<string>();
                        break;
                    case XmlElementNames.Rank:
                        this.Rank = reader.ReadElementValue<double>();
                        break;
                    case XmlElementNames.Content:
                        var type = reader.ReadAttributeValue("xsi:type");
                        switch (type)
                        { 
                            case XmlElementNames.SingleValueInsightContent:
                                this.Content = new SingleValueInsightContent();
                                ((SingleValueInsightContent)this.Content).LoadFromXml(reader, reader.LocalName);
                                break;
                            case XmlElementNames.MultiValueInsightContent:
                                this.Content = new MultiValueInsightContent();
                                ((MultiValueInsightContent)this.Content).LoadFromXml(reader, reader.LocalName);
                                break;
                            default:
                                return false;
                        }
                        break;
                    case XmlElementNames.ItemList:
                        this.ReadItemList(reader);
                        break;
                    default:
                        return false;
                }

                return true;
            }
        }
示例#9
0
 /// <summary>
 /// Reads attributes from XML.
 /// </summary>
 /// <param name="reader">The reader.</param>
 internal override void ReadAttributesFromXml(EwsServiceXmlReader reader)
 {
     this.bodyType = reader.ReadAttributeValue <BodyType>(XmlAttributeNames.BodyType);
 }
        /// <summary>
        /// Loads the attributes from XML.
        /// </summary>
        /// <param name="reader">The reader.</param>
        internal override void LoadAttributesFromXml(EwsServiceXmlReader reader)
        {
            base.LoadAttributesFromXml(reader);

            this.FolderId = reader.ReadAttributeValue(XmlAttributeNames.FolderId);
        }
        /// <summary>
        /// Reads ItemList from XML
        /// </summary>
        /// <param name="reader">The reader.</param>        
        private void ReadItemList(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;
                        case XmlElementNames.ComputedInsightValue:
                            item = new ComputedInsightValue();
                            item.LoadFromXml(reader, reader.LocalName);
                            this.ItemList.InternalAdd(item);
                            break;
                        case XmlElementNames.MeetingInsightValue:
                            item = new MeetingInsightValue();
                            item.LoadFromXml(reader, reader.LocalName);
                            this.ItemList.InternalAdd(item);
                            break;
                        case XmlElementNames.EmailInsightValue:
                            item = new EmailInsightValue();
                            item.LoadFromXml(reader, reader.LocalName);
                            this.ItemList.InternalAdd(item);
                            break;
                        case XmlElementNames.DelveDocument:
                            item = new DelveDocument();
                            item.LoadFromXml(reader, reader.LocalName);
                            this.ItemList.InternalAdd(item);
                            break;
                        case XmlElementNames.CompanyInsightValue:
                            item = new CompanyInsightValue();
                            item.LoadFromXml(reader, reader.LocalName);
                            this.ItemList.InternalAdd(item);
                            break;
                        case XmlElementNames.OutOfOfficeInsightValue:
                            item = new OutOfOfficeInsightValue();
                            item.LoadFromXml(reader, reader.LocalName);
                            this.ItemList.InternalAdd(item);
                            break;
                    }
                }
            } 
            while (!reader.IsEndElement(XmlNamespace.Types, XmlElementNames.ItemList));
        }
示例#12
0
 /// <summary>
 /// Reads the attributes from XML.
 /// </summary>
 /// <param name="reader">The reader.</param>
 internal override void ReadAttributesFromXml(EwsServiceXmlReader reader)
 {
     this.timeZoneName = reader.ReadAttributeValue(XmlAttributeNames.TimeZoneName);
 }
示例#13
0
        /// <summary>
        /// Loads from XML.
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <param name="xmlElementName">Name of the XML element.</param>
        internal void LoadFromXml(EwsServiceXmlReader reader, string xmlElementName)
        {
            reader.EnsureCurrentNodeIsStartElement(XmlNamespace.Types, xmlElementName);

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

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

            reader.ReadEndElement(XmlNamespace.Types, xmlElementName);
        }
 /// <summary>
 /// Reads attributes from XML.
 /// This should always be UTF-8 for MimeContentUTF8
 /// </summary>
 /// <param name="reader">The reader.</param>
 internal override void ReadAttributesFromXml(EwsServiceXmlReader reader)
 {
     this.characterSet = reader.ReadAttributeValue<string>(XmlAttributeNames.CharacterSet);
 }
        /// <summary>
        /// Loads the attributes from XML.
        /// </summary>
        /// <param name="reader">The reader.</param>
        internal override void LoadAttributesFromXml(EwsServiceXmlReader reader)
        {
            base.LoadAttributesFromXml(reader);

            this.FolderId = reader.ReadAttributeValue(XmlAttributeNames.FolderId);
        }
示例#16
0
 /// <summary>
 /// Reads the member Key attribute from XML.
 /// </summary>
 /// <param name="reader">The reader.</param>
 internal override void ReadAttributesFromXml(EwsServiceXmlReader reader)
 {
     this.key = reader.ReadAttributeValue<string>(XmlAttributeNames.Key);
 }
            /// <summary>
            /// Reads the attributes from XML.
            /// </summary>
            /// <param name="reader">The reader.</param>
            internal override void ReadAttributesFromXml(EwsServiceXmlReader reader)
            {
                base.ReadAttributesFromXml(reader);

                this.containmentMode = reader.ReadAttributeValue<ContainmentMode>(XmlAttributeNames.ContainmentMode);

                try
                {
                    this.comparisonMode = reader.ReadAttributeValue<ComparisonMode>(XmlAttributeNames.ContainmentComparison);
                }
                catch (ArgumentException)
                {
                    // This will happen if we receive a value that is defined in the EWS schema but that is not defined
                    // in the API (see the comments in ComparisonMode.cs). We map that value to IgnoreCaseAndNonSpacingCharacters.
                    this.comparisonMode = ComparisonMode.IgnoreCaseAndNonSpacingCharacters;
                }
            }
 /// <summary>
 /// Reads the attributes from XML.
 /// </summary>
 /// <param name="reader">The reader.</param>
 internal override void ReadAttributesFromXml(EwsServiceXmlReader reader)
 {
     this.id = reader.ReadAttributeValue(XmlAttributeNames.Id);
     this.name = reader.ReadAttributeValue(XmlAttributeNames.Name);
     this.bias = EwsUtilities.XSDurationToTimeSpan(reader.ReadAttributeValue(XmlAttributeNames.Bias));
 }
 /// <summary>
 /// Reads attributes from XML.
 /// </summary>
 /// <param name="reader">The reader.</param>
 internal override void ReadAttributesFromXml(EwsServiceXmlReader reader)
 {
     this.id = reader.ReadAttributeValue(XmlAttributeNames.Id);
 }
示例#20
0
    void ReadAttributesFromXml(EwsServiceXmlReader reader)
    {
        String value = reader.ReadAttributeValue(XmlAttributeNames.ClientExtensionType);

        if (!StringUtils.IsNullOrEmpty(value))
        {
            this.Type = reader.ReadAttributeValue <ExtensionType>(XmlAttributeNames.ClientExtensionType);
        }

        value = reader.ReadAttributeValue(XmlAttributeNames.ClientExtensionScope);
        if (!StringUtils.IsNullOrEmpty(value))
        {
            this.Scope = reader.ReadAttributeValue <ExtensionInstallScope>(XmlAttributeNames.ClientExtensionScope);
        }

        value = reader.ReadAttributeValue(XmlAttributeNames.ClientExtensionMarketplaceAssetID);
        if (!StringUtils.IsNullOrEmpty(value))
        {
            this.MarketplaceAssetID = reader.ReadAttributeValue <string>(XmlAttributeNames.ClientExtensionMarketplaceAssetID);
        }

        value = reader.ReadAttributeValue(XmlAttributeNames.ClientExtensionMarketplaceContentMarket);
        if (!StringUtils.IsNullOrEmpty(value))
        {
            this.MarketplaceContentMarket = reader.ReadAttributeValue <string>(XmlAttributeNames.ClientExtensionMarketplaceContentMarket);
        }

        value = reader.ReadAttributeValue(XmlAttributeNames.ClientExtensionAppStatus);
        if (!StringUtils.IsNullOrEmpty(value))
        {
            this.AppStatus = reader.ReadAttributeValue <string>(XmlAttributeNames.ClientExtensionAppStatus);
        }

        value = reader.ReadAttributeValue(XmlAttributeNames.ClientExtensionEtoken);
        if (!StringUtils.IsNullOrEmpty(value))
        {
            this.Etoken = reader.ReadAttributeValue <string>(XmlAttributeNames.ClientExtensionEtoken);
        }

        value = reader.ReadAttributeValue(XmlAttributeNames.ClientExtensionInstalledDateTime);
        if (!StringUtils.IsNullOrEmpty(value))
        {
            this.InstalledDateTime = reader.ReadAttributeValue <string>(XmlAttributeNames.ClientExtensionInstalledDateTime);
        }

        value = reader.ReadAttributeValue(XmlAttributeNames.ClientExtensionIsAvailable);
        if (!StringUtils.IsNullOrEmpty(value))
        {
            this.IsAvailable = reader.ReadAttributeValue <bool>(XmlAttributeNames.ClientExtensionIsAvailable);
        }

        value = reader.ReadAttributeValue(XmlAttributeNames.ClientExtensionIsMandatory);
        if (!StringUtils.IsNullOrEmpty(value))
        {
            this.IsMandatory = reader.ReadAttributeValue <bool>(XmlAttributeNames.ClientExtensionIsMandatory);
        }

        value = reader.ReadAttributeValue(XmlAttributeNames.ClientExtensionIsEnabledByDefault);
        if (!StringUtils.IsNullOrEmpty(value))
        {
            this.IsEnabledByDefault = reader.ReadAttributeValue <bool>(XmlAttributeNames.ClientExtensionIsEnabledByDefault);
        }

        value = reader.ReadAttributeValue(XmlAttributeNames.ClientExtensionProvidedTo);
        if (!StringUtils.IsNullOrEmpty(value))
        {
            this.ProvidedTo = reader.ReadAttributeValue <ClientExtensionProvidedTo>(XmlAttributeNames.ClientExtensionProvidedTo);
        }
    }
示例#21
0
 /// <summary>
 /// Reads the member Key attribute from XML.
 /// </summary>
 /// <param name="reader">The reader.</param>
 internal override void ReadAttributesFromXml(EwsServiceXmlReader reader)
 {
     this.key = reader.ReadAttributeValue <string>(XmlAttributeNames.Key);
 }
示例#22
0
 /// <summary>
 /// Loads the attributes from XML.
 /// </summary>
 /// <param name="reader">The reader.</param>
 internal virtual void LoadAttributesFromXml(EwsServiceXmlReader reader)
 {
     this.Format = reader.ReadAttributeValue<IdFormat>(XmlAttributeNames.Format);
 }
 /// <summary>
 /// Loads the attributes from XML.
 /// </summary>
 /// <param name="reader">The reader.</param>
 internal virtual void LoadAttributesFromXml(EwsServiceXmlReader reader)
 {
     this.Format = reader.ReadAttributeValue <IdFormat>(XmlAttributeNames.Format);
 }
        /// <summary>
        /// Reads attributes from XML.
        /// </summary>
        /// <param name="reader">The reader.</param>
        internal override void ReadAttributesFromXml(EwsServiceXmlReader reader)
        {
            string value = reader.ReadAttributeValue(XmlAttributeNames.ClientExtensionType);
            if (!string.IsNullOrEmpty(value))
            {
                this.Type = reader.ReadAttributeValue<ExtensionType>(XmlAttributeNames.ClientExtensionType);
            }

            value = reader.ReadAttributeValue(XmlAttributeNames.ClientExtensionScope);
            if (!string.IsNullOrEmpty(value))
            {
                this.Scope = reader.ReadAttributeValue<ExtensionInstallScope>(XmlAttributeNames.ClientExtensionScope);
            }
            
            value = reader.ReadAttributeValue(XmlAttributeNames.ClientExtensionMarketplaceAssetID);
            if (!string.IsNullOrEmpty(value))
            {
                this.MarketplaceAssetID = reader.ReadAttributeValue<string>(XmlAttributeNames.ClientExtensionMarketplaceAssetID);
            }

            value = reader.ReadAttributeValue(XmlAttributeNames.ClientExtensionMarketplaceContentMarket);
            if (!string.IsNullOrEmpty(value))
            {
                this.MarketplaceContentMarket = reader.ReadAttributeValue<string>(XmlAttributeNames.ClientExtensionMarketplaceContentMarket);
            }

            value = reader.ReadAttributeValue(XmlAttributeNames.ClientExtensionAppStatus);
            if (!string.IsNullOrEmpty(value))
            {
                this.AppStatus = reader.ReadAttributeValue<string>(XmlAttributeNames.ClientExtensionAppStatus);
            }

            value = reader.ReadAttributeValue(XmlAttributeNames.ClientExtensionEtoken);
            if (!string.IsNullOrEmpty(value))
            {
                this.Etoken = reader.ReadAttributeValue<string>(XmlAttributeNames.ClientExtensionEtoken);
            }

            value = reader.ReadAttributeValue(XmlAttributeNames.ClientExtensionInstalledDateTime);
            if (!string.IsNullOrEmpty(value))
            {
                this.InstalledDateTime = reader.ReadAttributeValue<string>(XmlAttributeNames.ClientExtensionInstalledDateTime);
            }

            value = reader.ReadAttributeValue(XmlAttributeNames.ClientExtensionIsAvailable);
            if (!string.IsNullOrEmpty(value))
            {
                this.IsAvailable = reader.ReadAttributeValue<bool>(XmlAttributeNames.ClientExtensionIsAvailable);
            }

            value = reader.ReadAttributeValue(XmlAttributeNames.ClientExtensionIsMandatory);
            if (!string.IsNullOrEmpty(value))
            {
                this.IsMandatory = reader.ReadAttributeValue<bool>(XmlAttributeNames.ClientExtensionIsMandatory);
            }

            value = reader.ReadAttributeValue(XmlAttributeNames.ClientExtensionIsEnabledByDefault);
            if (!string.IsNullOrEmpty(value))
            {
                this.IsEnabledByDefault = reader.ReadAttributeValue<bool>(XmlAttributeNames.ClientExtensionIsEnabledByDefault);
            }

            value = reader.ReadAttributeValue(XmlAttributeNames.ClientExtensionProvidedTo);
            if (!string.IsNullOrEmpty(value))
            {
                this.ProvidedTo = reader.ReadAttributeValue<ClientExtensionProvidedTo>(XmlAttributeNames.ClientExtensionProvidedTo);
            }
        }
            /// <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.Constant)
                    {
                        this.value = reader.ReadAttributeValue(XmlAttributeNames.Value);

                        result = true;
                    }
                }

                return result;
            }
        /// <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;
                        case XmlElementNames.ComputedInsightValue:
                            item = new ComputedInsightValue();
                            item.LoadFromXml(reader, reader.LocalName);
                            this.ItemList.InternalAdd(item);
                            break;
                        case XmlElementNames.MeetingInsightValue:
                            item = new MeetingInsightValue();
                            item.LoadFromXml(reader, reader.LocalName);
                            this.ItemList.InternalAdd(item);
                            break;
                        case XmlElementNames.EmailInsightValue:
                            item = new EmailInsightValue();
                            item.LoadFromXml(reader, reader.LocalName);
                            this.ItemList.InternalAdd(item);
                            break;
                        case XmlElementNames.DelveDocument:
                            item = new DelveDocument();
                            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;
        }
        /// <summary>
        /// Reads the attributes from XML.
        /// </summary>
        /// <param name="reader">The reader.</param>
        internal override void ReadAttributesFromXml(EwsServiceXmlReader reader)
        {
            this.name = reader.ReadAttributeValue(XmlAttributeNames.Name);
            this.id = reader.ReadAttributeValue(XmlAttributeNames.Id);

            // EWS can return a TimeZone definition with no Id. Generate a new Id in this case.
            if (string.IsNullOrEmpty(this.id))
            {
                string nameValue = string.IsNullOrEmpty(this.Name) ? string.Empty : this.Name;
                this.Id = NoIdPrefix + Math.Abs(nameValue.GetHashCode()).ToString();
            }
        }
 /// <summary>
 /// Reads the attributes from XML.
 /// </summary>
 /// <param name="reader">The reader.</param>
 internal override void ReadAttributesFromXml(EwsServiceXmlReader reader)
 {
     this.Traversal = reader.ReadAttributeValue<SearchFolderTraversal>(XmlAttributeNames.Traversal);
 }
示例#29
0
 /// <summary>
 /// Reads attributes from XML.
 /// </summary>
 /// <param name="reader">The reader.</param>
 internal override void ReadAttributesFromXml(EwsServiceXmlReader reader)
 {
     this.uniqueId = reader.ReadAttributeValue(XmlAttributeNames.Id);
     this.changeKey = reader.ReadAttributeValue(XmlAttributeNames.ChangeKey);
 }
        /// <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.To:
                    string targetKind = reader.ReadAttributeValue(XmlAttributeNames.Kind);
                    string targetId = reader.ReadElementValue();

                    switch (targetKind)
                    {
                        case TimeZoneTransition.PeriodTarget:
                            if (!this.timeZoneDefinition.Periods.TryGetValue(targetId, out this.targetPeriod))
                            {
                                throw new ServiceLocalException(
                                    string.Format(
                                        Strings.PeriodNotFound,
                                        targetId));
                            }

                            break;
                        case TimeZoneTransition.GroupTarget:
                            if (!this.timeZoneDefinition.TransitionGroups.TryGetValue(targetId, out this.targetGroup))
                            {
                                throw new ServiceLocalException(
                                    string.Format(
                                        Strings.TransitionGroupNotFound,
                                        targetId));
                            }

                            break;
                        default:
                            throw new ServiceLocalException(Strings.UnsupportedTimeZonePeriodTransitionTarget);
                    }

                    return true;
                default:
                    return false;
            }
        }
        /// <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);
        }
示例#32
0
    /// <summary>
    /// Reads ItemList from XML
    /// </summary>
    /// <param name="reader">The reader.</param>
    /* private */ void ReadItemList(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;

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

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

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

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

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

                case XmlElementNames.OutOfOfficeInsightValue:
                    item = new OutOfOfficeInsightValue();
                    item.LoadFromXml(reader, reader.LocalName);
                    this.ItemList.InternalAdd(item);
                    break;
                }
            }
        }while (!reader.IsEndElement(XmlNamespace.Types, XmlElementNames.ItemList));
    }
        /// <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));
        }
        /// <summary>
        /// Loads response from XML.
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <param name="xmlElementName">Name of the XML element.</param>
        internal void LoadFromXml(EwsServiceXmlReader reader, string xmlElementName)
        {
            if (!reader.IsStartElement(XmlNamespace.Messages, xmlElementName))
            {
                reader.ReadStartElement(XmlNamespace.Messages, xmlElementName);
            }

            this.result = reader.ReadAttributeValue<ServiceResult>(XmlAttributeNames.ResponseClass);

            if (this.result == ServiceResult.Success || this.result == ServiceResult.Warning)
            {
                if (this.result == ServiceResult.Warning)
                {
                    this.errorMessage = reader.ReadElementValue(XmlNamespace.Messages, XmlElementNames.MessageText);
                }
                else
                {
                    reader.ReadElementValue();
                    if (reader.IsStartElement(XmlNamespace.Messages, XmlElementNames.MessageText))
                    {
                        this.errorMessage = reader.ReadElementValue(XmlNamespace.Messages, XmlElementNames.MessageText);
                    }
                }

                this.errorCode = reader.ReadElementValue<ServiceError>(XmlNamespace.Messages, XmlElementNames.ResponseCode);

                if (this.result == ServiceResult.Warning)
                {
                    reader.ReadElementValue<int>(XmlNamespace.Messages, XmlElementNames.DescriptiveLinkKey);
                }

                // If batch processing stopped, EWS returns an empty element. Skip over it.
                if (this.BatchProcessingStopped)
                {
                    do
                    {
                        reader.Read();
                    }
                    while (!reader.IsEndElement(XmlNamespace.Messages, xmlElementName));
                }
                else
                {
                    this.ReadElementsFromXml(reader);

                    reader.ReadEndElementIfNecessary(XmlNamespace.Messages, xmlElementName);
                }
            }
            else
            {
                this.errorMessage = reader.ReadElementValue(XmlNamespace.Messages, XmlElementNames.MessageText);
                this.errorCode = reader.ReadElementValue<ServiceError>(XmlNamespace.Messages, XmlElementNames.ResponseCode);
                reader.ReadElementValue<int>(XmlNamespace.Messages, XmlElementNames.DescriptiveLinkKey);

                while (!reader.IsEndElement(XmlNamespace.Messages, xmlElementName))
                {
                    reader.Read();

                    if (reader.IsStartElement())
                    {
                        if (!this.LoadExtraErrorDetailsFromXml(reader, reader.LocalName))
                        {
                            reader.SkipCurrentElement();
                        }
                    }
                }
            }

            this.MapErrorCodeToErrorMessage();

            this.Loaded();
        }
示例#35
0
 void ReadAttributesFromXml(EwsServiceXmlReader reader)
 {
     this.name = reader.ReadAttributeValue(XmlAttributeNames.HeaderName);
 }
            /// <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;
            }
 /// <summary>
 /// Reads the attributes from XML.
 /// </summary>
 /// <param name="reader">The reader.</param>
 internal override void ReadAttributesFromXml(EwsServiceXmlReader reader)
 {
     this.Traversal = reader.ReadAttributeValue <SearchFolderTraversal>(XmlAttributeNames.Traversal);
 }
        /// <summary>
        /// Parses the message XML.
        /// </summary>
        /// <param name="reader">The reader.</param>
        private void ParseMessageXml(EwsServiceXmlReader reader)
        {
            do
            {
                reader.Read();

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

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

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

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

                        default:
                            break;
                    }
                }
            }
            while (!reader.IsEndElement(XmlNamespace.Messages, XmlElementNames.MessageXml));
        }