@@ -27,8 +27,7 @@ namespace log4net.Util.TypeConverters
27
27
/// </summary>
28
28
/// <remarks>
29
29
/// <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.
32
31
/// </para>
33
32
/// <para>
34
33
/// Use the <see cref="M:AddConverter(Type, object)"/> and
@@ -44,13 +43,8 @@ namespace log4net.Util.TypeConverters
44
43
public static class ConverterRegistry
45
44
{
46
45
/// <summary>
47
- /// Static constructor.
46
+ /// This class constructor adds the intrinsic type converters
48
47
/// </summary>
49
- /// <remarks>
50
- /// <para>
51
- /// This constructor defines the intrinsic type converters.
52
- /// </para>
53
- /// </remarks>
54
48
static ConverterRegistry ( )
55
49
{
56
50
// Add predefined converters here
@@ -67,23 +61,19 @@ static ConverterRegistry()
67
61
/// </summary>
68
62
/// <param name="destinationType">The type being converted to.</param>
69
63
/// <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>
75
64
public static void AddConverter ( Type ? destinationType , object ? converter )
76
65
{
77
- if ( destinationType is not null && converter is not null )
66
+ if ( destinationType is null || converter is null )
78
67
{
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 ;
87
77
}
88
78
}
89
79
@@ -92,15 +82,8 @@ public static void AddConverter(Type? destinationType, object? converter)
92
82
/// </summary>
93
83
/// <param name="destinationType">The type being converted to.</param>
94
84
/// <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>
100
85
public static void AddConverter ( Type destinationType , Type converterType )
101
- {
102
- AddConverter ( destinationType , CreateConverterInstance ( converterType ) ) ;
103
- }
86
+ => AddConverter ( destinationType , CreateConverterInstance ( converterType ) ) ;
104
87
105
88
/// <summary>
106
89
/// 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)
111
94
/// The type converter instance to use for type conversions or <c>null</c>
112
95
/// if no type converter is found.
113
96
/// </returns>
114
- /// <remarks>
115
- /// <para>
116
- /// Gets the type converter to use to convert values to the destination type.
117
- /// </para>
118
- /// </remarks>
119
97
public static IConvertTo ? GetConvertTo ( Type sourceType , Type destinationType )
120
98
{
121
99
// TODO: Support inheriting type converters.
@@ -146,11 +124,6 @@ public static void AddConverter(Type destinationType, Type converterType)
146
124
/// The type converter instance to use for type conversions or <c>null</c>
147
125
/// if no type converter is found.
148
126
/// </returns>
149
- /// <remarks>
150
- /// <para>
151
- /// Gets the type converter to use to convert values to the destination type.
152
- /// </para>
153
- /// </remarks>
154
127
public static IConvertFrom ? GetConvertFrom ( Type destinationType )
155
128
{
156
129
// TODO: Support inheriting type converters.
@@ -248,4 +221,4 @@ public static void AddConverter(Type destinationType, Type converterType)
248
221
private static readonly ConcurrentDictionary < Type , IConvertTo > s_type2ConvertTo = new ( ) ;
249
222
private static readonly ConcurrentDictionary < Type , IConvertFrom > s_type2ConvertFrom = new ( ) ;
250
223
}
251
- }
224
+ }
0 commit comments