You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4net-dev@logging.apache.org by ni...@apache.org on 2004/12/19 20:24:58 UTC
cvs commit: logging-log4net/src/Util/TypeConverters PatternStringConverter.cs
nicko 2004/12/19 11:24:58
Modified: src/Util/TypeConverters PatternStringConverter.cs
Log:
Updates suggested by FxCop.
Minor naming changes to internal types.
Perf improvements to type check + type cast code.
Revision Changes Path
1.4 +6 -4 logging-log4net/src/Util/TypeConverters/PatternStringConverter.cs
Index: PatternStringConverter.cs
===================================================================
RCS file: /home/cvs/logging-log4net/src/Util/TypeConverters/PatternStringConverter.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- PatternStringConverter.cs 23 Feb 2004 03:18:05 -0000 1.3
+++ PatternStringConverter.cs 19 Dec 2004 19:24:58 -0000 1.4
@@ -51,9 +51,10 @@
/// <returns>the converted object</returns>
public object ConvertTo(object source, Type targetType)
{
- if (typeof(string).IsAssignableFrom(targetType) && source is PatternString)
+ PatternString patternString = source as PatternString;
+ if (patternString != null && CanConvertTo(targetType))
{
- return ((PatternString)source).Format();
+ return patternString.Format();
}
throw ConversionNotSupportedException.Create(targetType, source);
}
@@ -82,9 +83,10 @@
/// <returns>the PatternString</returns>
public object ConvertFrom(object source)
{
- if (source is string)
+ string str = source as string;
+ if (str != null)
{
- return new PatternString((string)source);
+ return new PatternString(str);
}
throw ConversionNotSupportedException.Create(typeof(PatternString), source);
}