@@ -27,8 +27,7 @@ namespace log4net.Util.TypeConverters
2727 /// </summary>
2828 /// <remarks>
2929 /// <para>
30- /// Maintains a registry of type converters used to convert between
31- /// types.
30+ /// Maintains a registry of type converters used to convert between types.
3231 /// </para>
3332 /// <para>
3433 /// Use the <see cref="M:AddConverter(Type, object)"/> and
@@ -44,13 +43,8 @@ namespace log4net.Util.TypeConverters
4443 public static class ConverterRegistry
4544 {
4645 /// <summary>
47- /// Static constructor.
46+ /// This class constructor adds the intrinsic type converters
4847 /// </summary>
49- /// <remarks>
50- /// <para>
51- /// This constructor defines the intrinsic type converters.
52- /// </para>
53- /// </remarks>
5448 static ConverterRegistry ( )
5549 {
5650 // Add predefined converters here
@@ -67,23 +61,19 @@ static ConverterRegistry()
6761 /// </summary>
6862 /// <param name="destinationType">The type being converted to.</param>
6963 /// <param name="converter">The type converter to use to convert to the destination type.</param>
70- /// <remarks>
71- /// <para>
72- /// Adds a converter instance for a specific type.
73- /// </para>
74- /// </remarks>
7564 public static void AddConverter ( Type ? destinationType , object ? converter )
7665 {
77- if ( destinationType is not null && converter is not null )
66+ if ( destinationType is null || converter is null )
7867 {
79- if ( converter is IConvertTo convertTo )
80- {
81- s_type2ConvertTo [ destinationType ] = convertTo ;
82- }
83- else if ( converter is IConvertFrom convertFrom )
84- {
85- s_type2ConvertFrom [ destinationType ] = convertFrom ;
86- }
68+ return ;
69+ }
70+ if ( converter is IConvertTo convertTo )
71+ {
72+ s_type2ConvertTo [ destinationType ] = convertTo ;
73+ }
74+ if ( converter is IConvertFrom convertFrom )
75+ {
76+ s_type2ConvertFrom [ destinationType ] = convertFrom ;
8777 }
8878 }
8979
@@ -92,15 +82,8 @@ public static void AddConverter(Type? destinationType, object? converter)
9282 /// </summary>
9383 /// <param name="destinationType">The type being converted to.</param>
9484 /// <param name="converterType">The type of the type converter to use to convert to the destination type.</param>
95- /// <remarks>
96- /// <para>
97- /// Adds a converter <see cref="Type"/> for a specific type.
98- /// </para>
99- /// </remarks>
10085 public static void AddConverter ( Type destinationType , Type converterType )
101- {
102- AddConverter ( destinationType , CreateConverterInstance ( converterType ) ) ;
103- }
86+ => AddConverter ( destinationType , CreateConverterInstance ( converterType ) ) ;
10487
10588 /// <summary>
10689 /// Gets the type converter to use to convert values to the destination type.
@@ -111,11 +94,6 @@ public static void AddConverter(Type destinationType, Type converterType)
11194 /// The type converter instance to use for type conversions or <c>null</c>
11295 /// if no type converter is found.
11396 /// </returns>
114- /// <remarks>
115- /// <para>
116- /// Gets the type converter to use to convert values to the destination type.
117- /// </para>
118- /// </remarks>
11997 public static IConvertTo ? GetConvertTo ( Type sourceType , Type destinationType )
12098 {
12199 // TODO: Support inheriting type converters.
@@ -146,11 +124,6 @@ public static void AddConverter(Type destinationType, Type converterType)
146124 /// The type converter instance to use for type conversions or <c>null</c>
147125 /// if no type converter is found.
148126 /// </returns>
149- /// <remarks>
150- /// <para>
151- /// Gets the type converter to use to convert values to the destination type.
152- /// </para>
153- /// </remarks>
154127 public static IConvertFrom ? GetConvertFrom ( Type destinationType )
155128 {
156129 // TODO: Support inheriting type converters.
@@ -248,4 +221,4 @@ public static void AddConverter(Type destinationType, Type converterType)
248221 private static readonly ConcurrentDictionary < Type , IConvertTo > s_type2ConvertTo = new ( ) ;
249222 private static readonly ConcurrentDictionary < Type , IConvertFrom > s_type2ConvertFrom = new ( ) ;
250223 }
251- }
224+ }
0 commit comments