8000 Add documentation, remove whitespaces, final cleanup · dotnet/wpf@b4dde8a · GitHub
[go: up one dir, main page]

Skip to content

Commit b4dde8a

Browse files
committed
Add documentation, remove whitespaces, final cleanup
1 parent 201ee49 commit b4dde8a

File tree

1 file changed

+39
-34
lines changed

1 file changed

+39
-34
lines changed

src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/TextDecorationCollectionConverter.cs

Lines changed: 39 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,19 @@
99
namespace System.Windows
1010
{
1111
/// <summary>
12-
/// TypeConverter for TextDecorationCollection
13-
/// </summary>
12+
/// Provides a type converter to convert from <see langword="string"/> to <see cref="TextDecorationCollection"/> only.
13+
/// </summary>
1414
public sealed class TextDecorationCollectionConverter : TypeConverter
1515
{
1616
/// <summary>
17-
/// CanConvertTo method
17+
/// Returns whether this converter can convert the object to the specified
18+
/// <paramref name="destinationType"/>, using the specified <paramref name="context"/>.
1819
/// </summary>
19-
/// <param name="context"> ITypeDescriptorContext </param>
20-
/// <param name="destinationType"> Type to convert to </param>
21-
/// <returns> false will always be returned because TextDecorations cannot be converted to any other type. </returns>
20+
/// <param name="context">Context information used for conversion.</param>
21+
/// <param name="destinationType">Type being evaluated for conversion.</param>
22+
/// <returns>
23+
/// <see langword="false"/> will always be returned because <see cref="TextDecorations"/> cannot be converted to any other type.
24+
/// </returns>
2225
public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
2326
{
2427
// Return false for any other target type. Don't call base.CanConvertTo() because it would be confusing
@@ -28,44 +31,46 @@ public override bool CanConvertTo(ITypeDescriptorContext context, Type destinati
2831
}
2932

3033
/// <summary>
31-
/// CanConvertFrom
34+
/// Returns whether this class can convert specific <see cref="Type"/> into <see cref="TextDecorationCollection"/>.
3235
/// </summary>
3336
/// <param name="context"> ITypeDescriptorContext </param>
34-
/// <param name="sourceType">Type to convert to </param>
35-
/// <returns> true if it can convert from sourceType to TextDecorations, false otherwise </returns>
37+
/// <param name="sourceType">Type being evaluated for conversion.</param>
38+
/// <returns>
39+
/// <see langword="true"/> if <paramref name="sourceType"/> is <see langword="string"/>, otherwise <see langword="false"/>.
40+
/// </returns>
3641
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
3742
{
3843
return sourceType == typeof(string);
3944
}
4045

4146
/// <summary>
42-
/// ConvertFrom
47+
/// Converts <paramref name="input"/> of <see langword="string"/> type to its <see cref="TextDecorationCollection"/> represensation.
4348
/// </summary>
44-
/// <param name="context"> ITypeDescriptorContext </param>
45-
/// <param name="culture"> CultureInfo </param>
46-
/// <param name="input"> The input object to be converted to TextDecorations </param>
47-
/// <returns> the converted value of the input object </returns>
49+
/// <param name="context">Context information used for conversion, ignored currently.</param>
50+
/// <param name="culture">The culture specifier to use, ignored currently.</param>
51+
/// <param name="input">The string to convert from.</param>
52+
/// <returns>A <see cref="TextDecorationCollection"/> representing the <see langword="string"/> specified by <paramref name="input"/>.</returns>
4853
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object input)
4954
{
5055
if (input is null)
5156
throw GetConvertFromException(input);
5257

5358
if (input is not string value)
54-
throw new ArgumentException(SR.Format(SR.General_BadType, "ConvertFrom"), nameof(input));
55-
56-
return ConvertFromString(value);
59+
throw new ArgumentException(SR.Format(SR.General_BadType, "ConvertFrom"), nameof(input));
60+
61+
return ConvertFromString(value);
5762
}
5863

5964
/// <summary>
60-
/// ConvertFromString
65+
/// Converts <paramref name="text"/> to its <see cref="TextDecorationCollection"/> represensation.
6166
/// </summary>
62-
/// <param name="text"> The string to be converted into TextDecorationCollection object </param>
63-
/// <returns> the converted value of the string flag </returns>
67+
/// <param name="text">The string to be converted into TextDecorationCollection object.</param>
68+
/// <returns>A <see cref="TextDecorationCollection"/> representing the <see langword="string"/> specified by <paramref name="text"/>.</returns>
6469
/// <remarks>
65-
/// The text parameter can be either string "None" or a combination of the predefined
66-
/// TextDecoration names delimited by commas (,). One or more blanks spaces can precede
67-
/// or follow each text decoration name or comma. There can't be duplicate TextDecoration names in the
68-
/// string. The operation is case-insensitive.
70+
/// The text parameter can be either be <see langword="null"/>; <see cref="string.Empty"/>; the string "None"
71+
/// or a combination of the predefined <see cref="TextDecorations"/> names delimited by commas (,).
72+
/// One or more blanks spaces can precede or follow each text decoration name or comma.
73+
/// There can't be duplicate TextDecoration names in the string. The operation is case-insensitive.
6974
/// </remarks>
7075
public static new TextDecorationCollection ConvertFromString(string text)
7176
{
@@ -88,7 +93,7 @@ public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo c
8893
if (decorationsSpan.IsEmpty || decorationsSpan.Equals("None", StringComparison.OrdinalIgnoreCase))
8994
return new TextDecorationCollection();
9095

91-
// Create new collection, save allocations
96+
// Create new collection, save re-allocations
9297
TextDecorationCollection textDecorations = new(1 + decorationsSpan.Count(','));
9398

9499
// Go through each item in the input and match accordingly
@@ -123,16 +128,16 @@ public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo c
123128
}
124129

125130
return textDecorations;
126-
}
131+
}
127132

128133
/// <summary>
129-
/// ConvertTo
134+
/// Converts a <paramref name="value"/> of <see cref="TextDecorationCollection"/> to the specified <paramref name="destinationType"/>.
130135
/// </summary>
131-
/// <param name="context"> ITypeDescriptorContext </param>
132-
/// <param name="culture"> CultureInfo </param>
133-
/// <param name="value"> the object to be converted to another type </param>
134-
/// <param name="destinationType"> The destination type of the conversion </param>
135-
/// <returns> null will always be returned because TextDecorations cannot be converted to any other type. </returns>
136+
/// <param name="context">Context information used for conversion.</param>
137+
/// <param name="culture">The culture specifier to use.</param>
138+
/// <param name="value">Duration value to convert from.</param>
139+
/// <param name="destinationType">Type being evaluated for conversion.</param>
140+
/// <returns><see langword="null"/> will always be returned because <see cref="TextDecorations"/> cannot be converted to any other type.</returns>
136141
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
137142
{
138143
if (destinationType == typeof(InstanceDescriptor) && value is IEnumerable<TextDecoration>)
@@ -144,6 +149,6 @@ public override object ConvertTo(ITypeDescriptorContext context, CultureInfo cul
144149

145150
// Pass unhandled cases to base class (which will throw exceptions for null value or destinationType.)
146151
return base.ConvertTo(context, culture, value, destinationType);
147-
}
148-
}
152+
}
153+
}
149154
}

0 commit comments

Comments
 (0)
0