logging-log4net-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ni...@apache.org
Subject cvs commit: logging-log4net/src/Config XmlConfigurator.cs
Date Sun, 19 Dec 2004 19:22:41 GMT
nicko       2004/12/19 11:22:41

  Modified:    src/Config XmlConfigurator.cs
  Log:
  Updates suggested by FxCop.
  Minor naming changes to internal types.
  Perf improvements to type check + type cast code.
  
  Revision  Changes    Path
  1.10      +29 -14    logging-log4net/src/Config/XmlConfigurator.cs
  
  Index: XmlConfigurator.cs
  ===================================================================
  RCS file: /home/cvs/logging-log4net/src/Config/XmlConfigurator.cs,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- XmlConfigurator.cs	6 Dec 2004 02:21:16 -0000	1.9
  +++ XmlConfigurator.cs	19 Dec 2004 19:22:41 -0000	1.10
  @@ -623,7 +623,7 @@
   				{
   					// Create a watch handler that will reload the
   					// configuration whenever the config file is modified.
  -					new ConfigureAndWatchHandler(repository, configFile);
  +					ConfigureAndWatchHandler.StartWatching(repository, configFile);
   				}
   				catch(Exception ex)
   				{
  @@ -657,6 +657,21 @@
   		private sealed class ConfigureAndWatchHandler
   		{
   			/// <summary>
  +			/// Watch a specified config file used to configure a repository
  +			/// </summary>
  +			/// <param name="repository">The repository to configure.</param>
  +			/// <param name="configFile">The configuration file to watch.</param>
  +			/// <remarks>
  +			/// <para>
  +			/// Watch a specified config file used to configure a repository
  +			/// </para>
  +			/// </remarks>
  +			internal static void StartWatching(ILoggerRepository repository, FileInfo configFile)
  +			{
  +				ConfigureAndWatchHandler watcher = new ConfigureAndWatchHandler(repository, configFile);
  +			}
  +
  +			/// <summary>
   			/// Holds the FileInfo used to configure the XmlConfigurator
   			/// </summary>
   			private FileInfo m_configFile;
  @@ -687,7 +702,7 @@
   			/// Initializes a new instance of the <see cref="ConfigureAndWatchHandler" />
class.
   			/// </para>
   			/// </remarks>
  -			internal ConfigureAndWatchHandler(ILoggerRepository repository, FileInfo configFile)
  +			private ConfigureAndWatchHandler(ILoggerRepository repository, FileInfo configFile)
   			{
   				m_repository = repository;
   				m_configFile = configFile;
  @@ -796,22 +811,22 @@
   			{
   				LogLog.Debug("XmlConfigurator: Configuring Repository [" + repository.Name + "]");
   
  -				// Copy the xml data into the root of a new document
  -				// this isolates the xml config data from the rest of
  -				// the document
  -				XmlDocument newDoc = new XmlDocument();
  -				XmlElement newElement = (XmlElement) newDoc.AppendChild(newDoc.ImportNode(element,
true));
  -
  -				// Check the type of the repository
  -				if (repository is IXmlRepositoryConfigurator)
  +				IXmlRepositoryConfigurator configurableRepository = repository as IXmlRepositoryConfigurator;
  +				if (configurableRepository == null)
   				{
  -					// Pass the configurator the config element
  -					((IXmlRepositoryConfigurator) repository).Configure(newElement);
  +					LogLog.Warn("Repository [" + repository + "] does not support the XmlConfigurator");
   				}
   				else
   				{
  -					LogLog.Warn("Repository [" + repository + "] does not support the XmlConfigurator");
  -				}
  +					// Copy the xml data into the root of a new document
  +					// this isolates the xml config data from the rest of
  +					// the document
  +					XmlDocument newDoc = new XmlDocument();
  +					XmlElement newElement = (XmlElement)newDoc.AppendChild(newDoc.ImportNode(element,
true));
  +
  +					// Pass the configurator the config element
  +					configurableRepository.Configure(newElement);
  +				}			
   			}
   		}
   
  
  
  

Mime
View raw message