Skip to content

Commit a7ebafd

Browse files
committed
Documented the InternetAddress/List converters
1 parent 924c73b commit a7ebafd

File tree

2 files changed

+154
-10
lines changed

2 files changed

+154
-10
lines changed

MimeKit/InternetAddressConverter.cs

+77-5
Original file line numberDiff line numberDiff line change
@@ -58,19 +58,61 @@ public static void Register (ParserOptions options = null)
5858
TypeDescriptor.AddAttributes (typeof (InternetAddress), new TypeConverterAttribute (typeof (InternetAddressConverter)));
5959
}
6060

61-
/// <inheritdoc/>
61+
/// <summary>
62+
/// Initializes a new instance of the <see cref="InternetAddressConverter"/> class.
63+
/// </summary>
64+
/// <remarks>
65+
/// Creates a new <see cref="InternetAddressConverter"/>.
66+
/// </remarks>
67+
public InternetAddressConverter ()
68+
{
69+
}
70+
71+
/// <summary>
72+
/// Returns whether this converter can convert an object of the given type to the type of this converter, using the specified context.
73+
/// </summary>
74+
/// <remarks>
75+
/// Returns whether this converter can convert an object of the given type to the type of this converter, using the specified context.
76+
/// </remarks>
77+
/// <returns><see langword="true"/> if this converter can perform the conversion; otherwise, <see langword="false"/>.</returns>
78+
/// <param name="context">An <see cref="ITypeDescriptorContext"/> that provides a format context.</param>
79+
/// <param name="sourceType">A <see cref="Type"/> that represents the type you want to convert from.</param>
6280
public override bool CanConvertFrom (ITypeDescriptorContext context, Type sourceType)
6381
{
6482
return sourceType == typeof (string) || base.CanConvertFrom (context, sourceType);
6583
}
6684

67-
/// <inheritdoc/>
85+
/// <summary>
86+
/// Returns whether this converter can convert the object to the specified type, using the specified context.
87+
/// </summary>
88+
/// <remarks>
89+
/// <para>Use the <paramref name="context"/> parameter to extract additional information about the environment
90+
/// from which this converter is invoked. This parameter can be <see langword="null"/>, so always check it. Also,
91+
/// properties on the context object can return <see langword="null"/>.</para>
92+
/// <para>If <paramref name="destinationType"/> is a string, the default implementation of <see cref="CanConvertTo"/>
93+
/// always returns <see langword="true"/>.</para>
94+
/// </remarks>
95+
/// <returns><see langword="true"/> if this converter can perform the conversion; otherwise, <see langword="false"/>.</returns>
96+
/// <param name="context">An <see cref="ITypeDescriptorContext"/> that provides a format context.</param>
97+
/// <param name="destinationType">A <see cref="Type"/> that represents the type you want to convert to.</param>
6898
public override bool CanConvertTo (ITypeDescriptorContext context, Type destinationType)
6999
{
70100
return destinationType == typeof (string) || base.CanConvertTo (context, destinationType);
71101
}
72102

73-
/// <inheritdoc/>
103+
/// <summary>
104+
/// Converts the given object to the type of this converter, using the specified context and culture information.
105+
/// </summary>
106+
/// <remarks>
107+
/// Converts the given object to the type of this converter, using the specified context and culture information.
108+
/// </remarks>
109+
/// <returns>An <see cref="Object"/> that represents the converted value.</returns>
110+
/// <param name="context">An <see cref="ITypeDescriptorContext"/> that provides a format context.</param>
111+
/// <param name="culture">The <see cref="CultureInfo"/> to use as the current culture.</param>
112+
/// <param name="value">The <see cref="Object"/> to convert.</param>
113+
/// <exception cref="NotSupportedException">
114+
/// The conversion cannot be performed.
115+
/// </exception>
74116
public override object ConvertFrom (ITypeDescriptorContext context, CultureInfo culture, object value)
75117
{
76118
if (value is string text)
@@ -79,7 +121,23 @@ public override object ConvertFrom (ITypeDescriptorContext context, CultureInfo
79121
return base.ConvertFrom (context, culture, value);
80122
}
81123

82-
/// <inheritdoc/>
124+
/// <summary>
125+
/// Converts the given value object to the specified type, using the specified context and culture information.
126+
/// </summary>
127+
/// <remarks>
128+
/// Converts the given value object to the specified type, using the specified context and culture information.
129+
/// </remarks>
130+
/// <returns>An <see cref="Object"/> that represents the converted value.</returns>
131+
/// <param name="context">An <see cref="ITypeDescriptorContext"/> that provides a format context.</param>
132+
/// <param name="culture">A <see cref="CultureInfo"/>. If <see langword="null"/>, the current culture is assumed.</param>
133+
/// <param name="value">The <see cref="Object"/> to convert.</param>
134+
/// <param name="destinationType">The <see cref="Type"/> to convert the value to.</param>
135+
/// <exception cref="ArgumentNullException">
136+
/// <paramref name="destinationType"/> is <see langword="null"/>.
137+
/// </exception>
138+
/// <exception cref="NotSupportedException">
139+
/// The conversion cannot be performed.
140+
/// </exception>
83141
public override object ConvertTo (ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
84142
{
85143
if (destinationType == typeof (string) && value is InternetAddress address)
@@ -88,7 +146,21 @@ public override object ConvertTo (ITypeDescriptorContext context, CultureInfo cu
88146
return base.ConvertTo (context, culture, value, destinationType);
89147
}
90148

91-
/// <inheritdoc/>
149+
/// <summary>
150+
/// Returns whether the given value object is valid for this type and for the specified context.
151+
/// </summary>
152+
/// <remarks>
153+
/// <para>Use the <paramref name="context"/> parameter to extract additional information about the environment from which
154+
/// this converter is invoked. This parameter can be <see langword="null"/>, so always check it. Also, properties on the
155+
/// context object can return <see langword="null"/>.</para>
156+
/// <para>Starting in .NET Framework 4, the <see cref="IsValid"/> method catches exceptions from the <see cref="CanConvertFrom"/>
157+
/// and <see cref="ConvertFrom"/> methods. If the input value type causes <see cref="CanConvertFrom"/> to return <see langword="false"/>,
158+
/// or if the input value causes <see cref="ConvertFrom"/> to raise an exception, the <see cref="IsValid"/> method returns
159+
/// <see langword="false"/>.</para>
160+
/// </remarks>
161+
/// <returns><see langword="true"/> if the specified value is valid for this object; otherwise, <see langword="false"/>.</returns>
162+
/// <param name="context">An <see cref="ITypeDescriptorContext"/> that provides a format context.</param>
163+
/// <param name="value">The <see cref="Object"/> to test for validity.</param>
92164
public override bool IsValid (ITypeDescriptorContext context, object value)
93165
{
94166
if (value is string text)

MimeKit/InternetAddressListConverter.cs

+77-5
Original file line numberDiff line numberDiff line change
@@ -58,19 +58,61 @@ public static void Register (ParserOptions options = null)
5858
TypeDescriptor.AddAttributes (typeof (InternetAddressList), new TypeConverterAttribute (typeof (InternetAddressListConverter)));
5959
}
6060

61-
/// <inheritdoc/>
61+
/// <summary>
62+
/// Initializes a new instance of the <see cref="InternetAddressListConverter"/> class.
63+
/// </summary>
64+
/// <remarks>
65+
/// Creates a new <see cref="InternetAddressListConverter"/>.
66+
/// </remarks>
67+
public InternetAddressListConverter ()
68+
{
69+
}
70+
71+
/// <summary>
72+
/// Returns whether this converter can convert an object of the given type to the type of this converter, using the specified context.
73+
/// </summary>
74+
/// <remarks>
75+
/// Returns whether this converter can convert an object of the given type to the type of this converter, using the specified context.
76+
/// </remarks>
77+
/// <returns><see langword="true"/> if this converter can perform the conversion; otherwise, <see langword="false"/>.</returns>
78+
/// <param name="context">An <see cref="ITypeDescriptorContext"/> that provides a format context.</param>
79+
/// <param name="sourceType">A <see cref="Type"/> that represents the type you want to convert from.</param>
6280
public override bool CanConvertFrom (ITypeDescriptorContext context, Type sourceType)
6381
{
6482
return sourceType == typeof (string) || base.CanConvertFrom (context, sourceType);
6583
}
6684

67-
/// <inheritdoc/>
85+
/// <summary>
86+
/// Returns whether this converter can convert the object to the specified type, using the specified context.
87+
/// </summary>
88+
/// <remarks>
89+
/// <para>Use the <paramref name="context"/> parameter to extract additional information about the environment
90+
/// from which this converter is invoked. This parameter can be <see langword="null"/>, so always check it. Also,
91+
/// properties on the context object can return <see langword="null"/>.</para>
92+
/// <para>If <paramref name="destinationType"/> is a string, the default implementation of <see cref="CanConvertTo"/>
93+
/// always returns <see langword="true"/>.</para>
94+
/// </remarks>
95+
/// <returns><see langword="true"/> if this converter can perform the conversion; otherwise, <see langword="false"/>.</returns>
96+
/// <param name="context">An <see cref="ITypeDescriptorContext"/> that provides a format context.</param>
97+
/// <param name="destinationType">A <see cref="Type"/> that represents the type you want to convert to.</param>
6898
public override bool CanConvertTo (ITypeDescriptorContext context, Type destinationType)
6999
{
70100
return destinationType == typeof (string) || base.CanConvertTo (context, destinationType);
71101
}
72102

73-
/// <inheritdoc/>
103+
/// <summary>
104+
/// Converts the given object to the type of this converter, using the specified context and culture information.
105+
/// </summary>
106+
/// <remarks>
107+
/// Converts the given object to the type of this converter, using the specified context and culture information.
108+
/// </remarks>
109+
/// <returns>An <see cref="Object"/> that represents the converted value.</returns>
110+
/// <param name="context">An <see cref="ITypeDescriptorContext"/> that provides a format context.</param>
111+
/// <param name="culture">The <see cref="CultureInfo"/> to use as the current culture.</param>
112+
/// <param name="value">The <see cref="Object"/> to convert.</param>
113+
/// <exception cref="NotSupportedException">
114+
/// The conversion cannot be performed.
115+
/// </exception>
74116
public override object ConvertFrom (ITypeDescriptorContext context, CultureInfo culture, object value)
75117
{
76118
if (value is string text)
@@ -79,7 +121,23 @@ public override object ConvertFrom (ITypeDescriptorContext context, CultureInfo
79121
return base.ConvertFrom (context, culture, value);
80122
}
81123

82-
/// <inheritdoc/>
124+
/// <summary>
125+
/// Converts the given value object to the specified type, using the specified context and culture information.
126+
/// </summary>
127+
/// <remarks>
128+
/// Converts the given value object to the specified type, using the specified context and culture information.
129+
/// </remarks>
130+
/// <returns>An <see cref="Object"/> that represents the converted value.</returns>
131+
/// <param name="context">An <see cref="ITypeDescriptorContext"/> that provides a format context.</param>
132+
/// <param name="culture">A <see cref="CultureInfo"/>. If <see langword="null"/>, the current culture is assumed.</param>
133+
/// <param name="value">The <see cref="Object"/> to convert.</param>
134+
/// <param name="destinationType">The <see cref="Type"/> to convert the value to.</param>
135+
/// <exception cref="ArgumentNullException">
136+
/// <paramref name="destinationType"/> is <see langword="null"/>.
137+
/// </exception>
138+
/// <exception cref="NotSupportedException">
139+
/// The conversion cannot be performed.
140+
/// </exception>
83141
public override object ConvertTo (ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
84142
{
85143
if (destinationType == typeof (string) && value is InternetAddressList list)
@@ -88,7 +146,21 @@ public override object ConvertTo (ITypeDescriptorContext context, CultureInfo cu
88146
return base.ConvertTo (context, culture, value, destinationType);
89147
}
90148

91-
/// <inheritdoc/>
149+
/// <summary>
150+
/// Returns whether the given value object is valid for this type and for the specified context.
151+
/// </summary>
152+
/// <remarks>
153+
/// <para>Use the <paramref name="context"/> parameter to extract additional information about the environment from which
154+
/// this converter is invoked. This parameter can be <see langword="null"/>, so always check it. Also, properties on the
155+
/// context object can return <see langword="null"/>.</para>
156+
/// <para>Starting in .NET Framework 4, the <see cref="IsValid"/> method catches exceptions from the <see cref="CanConvertFrom"/>
157+
/// and <see cref="ConvertFrom"/> methods. If the input value type causes <see cref="CanConvertFrom"/> to return <see langword="false"/>,
158+
/// or if the input value causes <see cref="ConvertFrom"/> to raise an exception, the <see cref="IsValid"/> method returns
159+
/// <see langword="false"/>.</para>
160+
/// </remarks>
161+
/// <returns><see langword="true"/> if the specified value is valid for this object; otherwise, <see langword="false"/>.</returns>
162+
/// <param name="context">An <see cref="ITypeDescriptorContext"/> that provides a format context.</param>
163+
/// <param name="value">The <see cref="Object"/> to test for validity.</param>
92164
public override bool IsValid (ITypeDescriptorContext context, object value)
93165
{
94166
if (value is string text)

0 commit comments

Comments
 (0)