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/Repository/Hierarchy XmlHierarchyConfigurator.cs
Date Sun, 19 Dec 2004 19:24:07 GMT
nicko       2004/12/19 11:24:07

  Modified:    src/Repository/Hierarchy XmlHierarchyConfigurator.cs
  Log:
  Updates suggested by FxCop.
  Minor naming changes to internal types.
  Perf improvements to type check + type cast code.
  
  Revision  Changes    Path
  1.14      +24 -16    logging-log4net/src/Repository/Hierarchy/XmlHierarchyConfigurator.cs
  
  Index: XmlHierarchyConfigurator.cs
  ===================================================================
  RCS file: /home/cvs/logging-log4net/src/Repository/Hierarchy/XmlHierarchyConfigurator.cs,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- XmlHierarchyConfigurator.cs	13 Dec 2004 01:42:51 -0000	1.13
  +++ XmlHierarchyConfigurator.cs	19 Dec 2004 19:24:07 -0000	1.14
  @@ -242,11 +242,11 @@
   
   				if (appenderName != null && appenderName.Length > 0)
   				{
  -					foreach (XmlNode node in appenderRef.OwnerDocument.GetElementsByTagName(APPENDER_TAG))
  +					foreach (XmlElement curAppenderElement in appenderRef.OwnerDocument.GetElementsByTagName(APPENDER_TAG))
   					{
  -						if (((XmlElement)node).GetAttribute("name") == appenderName)
  +						if (curAppenderElement.GetAttribute("name") == appenderName)
   						{
  -							element = (XmlElement)node;
  +							element = curAppenderElement;
   							break;
   						}
   					}
  @@ -302,14 +302,16 @@
   						if (currentElement.LocalName == APPENDER_REF_TAG)
   						{
   							string refName = currentElement.GetAttribute(REF_ATTR);
  -							if (appender is IAppenderAttachable) 
  +
  +							IAppenderAttachable appenderContainer = appender as IAppenderAttachable;
  +							if (appenderContainer != null) 
   							{
  -								IAppenderAttachable aa = (IAppenderAttachable) appender;
   								LogLog.Debug("XmlConfigurator: Attaching appender named [" + refName + "] to appender
named [" + appender.Name + "].");
  -								IAppender a = FindAppenderByReference(currentElement);
  -								if (a != null)
  +
  +								IAppender referencedAppender = FindAppenderByReference(currentElement);
  +								if (referencedAppender != null)
   								{
  -									aa.AddAppender(a);
  +									appenderContainer.AddAppender(referencedAppender);
   								}
   							} 
   							else 
  @@ -324,17 +326,20 @@
   						}
   					}
   				}
  -				if (appender is IOptionHandler) 
  +
  +				IOptionHandler optionHandler = appender as IOptionHandler;
  +				if (optionHandler != null) 
   				{
  -					((IOptionHandler) appender).ActivateOptions();
  +					optionHandler.ActivateOptions();
   				}
   
   				LogLog.Debug("XmlConfigurator: Created Appender [" + appenderName + "]");	
   				return appender;
   			}
  -				/* Yes, it's ugly.  But all of these exceptions point to the same problem: we can't
create an Appender */
   			catch (Exception ex) 
   			{
  +				// Yes, it's ugly.  But all exceptions point to the same problem: we can't create an
Appender
  +
   				LogLog.Error("XmlConfigurator: Could not create Appender [" + appenderName + "] of
type [" + typeName + "]. Reported error follows.", ex);
   				return null;
   			}
  @@ -436,9 +441,11 @@
   					}
   				}
   			}
  -			if (log is IOptionHandler) 
  +
  +			IOptionHandler optionHandler = log as IOptionHandler;
  +			if (optionHandler != null) 
   			{
  -				((IOptionHandler) log).ActivateOptions();
  +				optionHandler.ActivateOptions();
   			}
   		}
   
  @@ -889,7 +896,7 @@
   				}
   			}
   
  -			// Look for the default constructor
  +			// Create using the default constructor
   			object createdObject = null;
   			try
   			{
  @@ -910,9 +917,10 @@
   			}
   
   			// Check if we need to call ActivateOptions
  -			if (createdObject is IOptionHandler)
  +			IOptionHandler optionHandler = createdObject as IOptionHandler;
  +			if (optionHandler != null)
   			{
  -				((IOptionHandler) createdObject).ActivateOptions();
  +				optionHandler.ActivateOptions();
   			}
   
   			// Ok object should be initialized
  
  
  

Mime
View raw message