Пример #1
0
        /// <summary>
        /// Reads user setting from XML.
        /// </summary>
        /// <param name="reader">The reader.</param>
        private void ReadSettingFromXml(EwsXmlReader reader)
        {
            string name  = null;
            object value = null;

            do
            {
                reader.Read();

                if (reader.NodeType == XmlNodeType.Element)
                {
                    switch (reader.LocalName)
                    {
                    case XmlElementNames.Name:
                        name = reader.ReadElementValue <string>();
                        break;

                    case XmlElementNames.Value:
                        value = reader.ReadElementValue();
                        break;

                    case XmlElementNames.WebClientUrls:
                        value = WebClientUrlCollection.LoadFromXml(reader);
                        break;

                    case XmlElementNames.ProtocolConnections:
                        value = ProtocolConnectionCollection.LoadFromXml(reader);
                        break;

                    case XmlElementNames.AlternateMailboxes:
                        value = AlternateMailboxCollection.LoadFromXml(reader);
                        break;

                    case XmlElementNames.DocumentSharingLocations:
                        value = DocumentSharingLocationCollection.LoadFromXml(reader);
                        break;
                    }
                }
            }while (!reader.IsEndElement(XmlNamespace.Autodiscover, XmlElementNames.UserSetting));

            // EWS Managed API is broken with AutoDSvc endpoint in RedirectUrl scenario
            try
            {
                UserSettingName userSettingName = EwsUtilities.Parse <UserSettingName>(name);
                this.Settings.Add(userSettingName, value);
            }
            catch (ArgumentException)
            {
                // ignore unexpected UserSettingName in the response (due to the server-side bugs).
                // it'd be better if this is hooked into ITraceListener, but that is unavailable here.
                //
                // in case "name" is null, EwsUtilities.Parse throws ArgumentNullException
                // (which derives from ArgumentException).
                //
                EwsUtilities.Assert(
                    false,
                    "GetUserSettingsResponse.ReadSettingFromXml",
                    "Unexpected or empty name element in user setting");
            }
        }
        /// <summary>
        /// Read user setting with ProtocolConnectionCollection value.
        /// </summary>
        /// <param name="reader">EwsServiceXmlReader</param>
        internal static ProtocolConnectionCollection LoadFromXml(EwsXmlReader reader)
        {
            ProtocolConnectionCollection value = new ProtocolConnectionCollection();
            ProtocolConnection connection = null;

            do
            {
                reader.Read();

                if (reader.NodeType == XmlNodeType.Element)
                {
                    if (reader.LocalName == XmlElementNames.ProtocolConnection)
                    {
                        connection = ProtocolConnection.LoadFromXml(reader);
                        if (connection != null)
                        {
                            value.Connections.Add(connection);
                        }
                    }
                }
            }
            while (!reader.IsEndElement(XmlNamespace.Autodiscover, XmlElementNames.ProtocolConnections));

            return value;
        }
Пример #3
0
        /// <summary>
        /// Read user setting with ProtocolConnectionCollection value.
        /// </summary>
        /// <param name="reader">EwsServiceXmlReader</param>
        internal static ProtocolConnectionCollection LoadFromXml(EwsXmlReader reader)
        {
            ProtocolConnectionCollection value      = new ProtocolConnectionCollection();
            ProtocolConnection           connection = null;

            do
            {
                reader.Read();

                if (reader.NodeType == XmlNodeType.Element)
                {
                    if (reader.LocalName == XmlElementNames.ProtocolConnection)
                    {
                        connection = ProtocolConnection.LoadFromXml(reader);
                        if (connection != null)
                        {
                            value.Connections.Add(connection);
                        }
                    }
                }
            }while (!reader.IsEndElement(XmlNamespace.Autodiscover, XmlElementNames.ProtocolConnections));

            return(value);
        }