예제 #1
0
        /// <summary>
        /// Deserializes an individual configuration setting.
        /// </summary>
        /// <param name="reader">The XmlReader containing the setting to deserialize.</param>
        /// <returns>A <see cref="T:Microsoft.Exchange.Data.Internal.CtsConfigurationSetting" /> instance containing the configuration setting.</returns>
        private static CtsConfigurationSetting DeserializeSetting(XmlReader reader)
        {
            string name = reader.Name;
            CtsConfigurationSetting ctsConfigurationSetting = new CtsConfigurationSetting(name);

            if (reader.AttributeCount > 0)
            {
                while (reader.MoveToNextAttribute())
                {
                    string name2 = reader.Name;
                    string value = reader.Value;
                    ctsConfigurationSetting.AddArgument(name2, value);
                }
            }
            return(ctsConfigurationSetting);
        }
예제 #2
0
        /// <summary>
        /// Gets the specified configuration setting.
        /// </summary>
        /// <param name="subSectionName">Name of the configuration sub section.</param>
        /// <param name="settingName">Name of the configuration setting.</param>
        /// <returns>A <see cref="T:Microsoft.Exchange.Data.Internal.CtsConfigurationSetting" /> for the sepecified setting from the specified sub section.</returns>
        public static CtsConfigurationSetting GetSimpleConfigurationSetting(string subSectionName, string settingName)
        {
            CtsConfigurationSetting         ctsConfigurationSetting = null;
            IList <CtsConfigurationSetting> configuration           = Provider.GetConfiguration(subSectionName);

            foreach (CtsConfigurationSetting current in from setting in configuration
                     where string.Equals(setting.Name, settingName, StringComparison.OrdinalIgnoreCase)
                     select setting)
            {
                if (ctsConfigurationSetting != null)
                {
                    Provider.LogConfigurationErrorEvent();
                    break;
                }
                ctsConfigurationSetting = current;
            }
            return(ctsConfigurationSetting);
        }
예제 #3
0
        /// <summary>
        /// Gets the configuration subsection specified.
        /// </summary>
        /// <param name="subSectionName">Name of the subsection.</param>
        /// <returns>
        /// A list of <see cref="T:Microsoft.Exchange.Data.Internal.CtsConfigurationSetting" />s for the specified section.
        /// </returns>
        public IList <CtsConfigurationSetting> GetConfiguration(string subSectionName)
        {
            IList <CtsConfigurationSetting> list;

            if (this.configurationSubSections == null)
            {
                lock (this.lockObject)
                {
                    if (this.configurationSubSections == null)
                    {
                        try
                        {
                            CtsConfigurationSection ctsConfigurationSection = ConfigurationManager.GetSection("CTS") as CtsConfigurationSection;
                            if (ctsConfigurationSection != null)
                            {
                                this.configurationSubSections = ctsConfigurationSection.SubSectionsDictionary;
                            }
                            else
                            {
                                this.configurationSubSections = new Dictionary <string, IList <CtsConfigurationSetting> >
                                {
                                    {
                                        string.Empty,
                                        new List <CtsConfigurationSetting>()
                                    }
                                };
                            }
                            string value = ConfigurationManager.AppSettings["TemporaryStoragePath"];
                            if (!string.IsNullOrEmpty(value))
                            {
                                CtsConfigurationSetting ctsConfigurationSetting = new CtsConfigurationSetting("TemporaryStorage");
                                ctsConfigurationSetting.AddArgument("Path", value);
                                list = this.configurationSubSections[string.Empty];
                                list.Add(ctsConfigurationSetting);
                            }
                            ConfigurationManager.RefreshSection("CTS");
                        }
                        catch (ConfigurationErrorsException)
                        {
                            ApplicationServices.Provider.LogConfigurationErrorEvent();
                            this.configurationSubSections = new Dictionary <string, IList <CtsConfigurationSetting> >
                            {
                                {
                                    string.Empty,
                                    new List <CtsConfigurationSetting>()
                                }
                            };
                        }
                    }
                }
            }
            if (subSectionName == null)
            {
                subSectionName = string.Empty;
            }
            if (!this.configurationSubSections.TryGetValue(subSectionName, out list))
            {
                list = DefaultApplicationServices.EmptySubSection;
            }
            return(list);
        }
예제 #4
0
        /// <summary>
        /// Deserailizes a configuration section.
        /// </summary>
        /// <param name="reader">An XmlReader containing the section to deserialize.</param>
        protected override void DeserializeSection(XmlReader reader)
        {
            IList <CtsConfigurationSetting> list = new List <CtsConfigurationSetting>();

            subSections.Add(string.Empty, list);
            if (!reader.Read() || reader.NodeType != XmlNodeType.Element)
            {
                throw new ConfigurationErrorsException("error", reader);
            }
            if (!reader.IsEmptyElement)
            {
                while (reader.Read())
                {
                    XmlNodeType nodeType = reader.NodeType;
                    switch (nodeType)
                    {
                    case XmlNodeType.Element:
                        if (reader.IsEmptyElement)
                        {
                            CtsConfigurationSetting item = DeserializeSetting(reader);
                            list.Add(item);
                        }
                        else
                        {
                            string name = reader.Name;
                            IList <CtsConfigurationSetting> list2;
                            if (!subSections.TryGetValue(name, out list2))
                            {
                                list2 = new List <CtsConfigurationSetting>();
                                subSections.Add(name, list2);
                            }
                            while (reader.Read())
                            {
                                XmlNodeType nodeType2 = reader.NodeType;
                                switch (nodeType2)
                                {
                                case XmlNodeType.Element:
                                {
                                    if (!reader.IsEmptyElement)
                                    {
                                        throw new ConfigurationErrorsException("error", reader);
                                    }
                                    CtsConfigurationSetting item2 = DeserializeSetting(reader);
                                    list2.Add(item2);
                                    break;
                                }

                                case XmlNodeType.Attribute:
                                    break;

                                case XmlNodeType.Text:
                                case XmlNodeType.CDATA:
                                    throw new ConfigurationErrorsException("error", reader);

                                default:
                                    if (nodeType2 != XmlNodeType.EndElement)
                                    {
                                    }
                                    break;
                                }
                            }
                        }
                        break;

                    case XmlNodeType.Attribute:
                        break;

                    case XmlNodeType.Text:
                    case XmlNodeType.CDATA:
                        throw new ConfigurationErrorsException("error", reader);

                    default:
                        if (nodeType != XmlNodeType.EndElement)
                        {
                        }
                        break;
                    }
                }
            }
        }