Represents the configuration section for the logging aspect
See also base object System.Configuration.ConfigurationSection http://www.codeproject.com/Articles/32490/Custom-Configuration-Sections-for-Lazy-Coders
Inheritance: System.Configuration.ConfigurationSection
コード例 #1
0
ファイル: LogAspectSection.cs プロジェクト: vnvizitiu/AOP
        /// <summary>
        /// Get this configuration set from a specific config file
        /// </summary>
        /// <param name="path"> The path. </param>
        /// <returns> The <see cref="LogAspectConfig"/>. </returns>
        public static LogAspectConfig Open(string path)
        {
            if (path == null)
            {
                throw new ArgumentNullException("path");
            }

            if (instance == null)
            {
                originalConfigPath = path.EndsWith(".config", StringComparison.OrdinalIgnoreCase)
                                         ? path.Remove(path.Length - 7)
                                         : path;

                Configuration config = ConfigurationManager.OpenExeConfiguration(originalConfigPath);

                if (config.Sections[LogAspectSectionName] == null)
                {
                    instance = new LogAspectConfig();
                    config.Sections.Add(LogAspectSectionName, instance);
                    config.Save(ConfigurationSaveMode.Modified);
                }
                else
                {
                    instance = (LogAspectConfig)config.Sections[LogAspectSectionName];
                }
            }

            return(instance);
        }
コード例 #2
0
ファイル: LogAspectSection.cs プロジェクト: vnvizitiu/AOP
        /// <summary>
        /// Save the current property values to the config file
        /// </summary>
        // ReSharper disable once UnusedMember.Global
        public void Save()
        {
            Configuration   config  = ConfigurationManager.OpenExeConfiguration(originalConfigPath);
            LogAspectConfig section = Open(originalConfigPath);

            section.UseConsoleLogger = UseConsoleLogger;
            section.Logger           = Logger;

            config.Save(ConfigurationSaveMode.Full);
        }
コード例 #3
0
ファイル: LogAspectSection.cs プロジェクト: vnvizitiu/AOP
        /// <summary>
        /// The copy.
        /// </summary>
        /// <returns> The <see cref="LogAspectConfig"/>. </returns>
        // ReSharper disable once UnusedMember.Global
        public LogAspectConfig Copy()
        {
            LogAspectConfig copy = new LogAspectConfig();
            string          xml  = SerializeSection(this, LogAspectSectionName, ConfigurationSaveMode.Full);

            using (StringReader stringReader = new StringReader(xml))
            {
                XmlReader reader = new XmlTextReader(stringReader);
                copy.DeserializeSection(reader);
                return(copy);
            }
        }
コード例 #4
0
ファイル: LogAspectSection.cs プロジェクト: vnvizitiu/AOP
 /// <summary>
 /// The copy.
 /// </summary>
 /// <returns> The <see cref="LogAspectConfig"/>. </returns>
 // ReSharper disable once UnusedMember.Global
 public LogAspectConfig Copy()
 {
     LogAspectConfig copy = new LogAspectConfig();
     string xml = SerializeSection(this, LogAspectSectionName, ConfigurationSaveMode.Full);
     using (StringReader stringReader = new StringReader(xml))
     {
         XmlReader reader = new XmlTextReader(stringReader);
         copy.DeserializeSection(reader);
         return copy;
     }
 }
コード例 #5
0
ファイル: LogAspectSection.cs プロジェクト: vnvizitiu/AOP
        /// <summary>
        /// Get this configuration set from a specific config file
        /// </summary>
        /// <param name="path"> The path. </param>
        /// <returns> The <see cref="LogAspectConfig"/>. </returns>
        public static LogAspectConfig Open(string path)
        {
            if (path == null) throw new ArgumentNullException("path");

            if (instance == null)
            {
                originalConfigPath = path.EndsWith(".config", StringComparison.OrdinalIgnoreCase)
                                         ? path.Remove(path.Length - 7)
                                         : path;

                Configuration config = ConfigurationManager.OpenExeConfiguration(originalConfigPath);

                if (config.Sections[LogAspectSectionName] == null)
                {
                    instance = new LogAspectConfig();
                    config.Sections.Add(LogAspectSectionName, instance);
                    config.Save(ConfigurationSaveMode.Modified);
                }
                else
                {
                    instance = (LogAspectConfig)config.Sections[LogAspectSectionName];
                }
            }

            return instance;
        }