/// <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); }
/// <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); }
/// <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); } }
/// <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; } }
/// <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; }