Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
namespace System.ComponentModel
{
/// <summary>
/// Provides a type converter to convert <see cref='System.DateOnly'/>
/// objects to and from various other representations.
/// Provides a type converter to convert <see cref='System.DateOnly'/> objects to and from various other representations.
/// </summary>
public class DateOnlyConverter : TypeConverter
{
Expand All @@ -19,6 +18,9 @@ public class DateOnlyConverter : TypeConverter
/// object in the given source type to a <see cref='System.DateOnly'/>
/// object using the specified context.
/// </summary>
/// <param name="context">An <see cref="T:System.ComponentModel.ITypeDescriptorContext" /> that provides a format context.</param>
/// <param name="sourceType">The type to convert from.</param>
/// <returns><see langword="true" /> if this object can perform the conversion; otherwise, <see langword="false" />.</returns>
public override bool CanConvertFrom(ITypeDescriptorContext? context, Type sourceType)
{
return sourceType == typeof(string) || base.CanConvertFrom(context, sourceType);
Expand All @@ -28,6 +30,9 @@ public override bool CanConvertFrom(ITypeDescriptorContext? context, Type source
/// Gets a value indicating whether this converter can convert an object
/// to the given destination type using the context.
/// </summary>
/// <param name="context">An <see cref="T:System.ComponentModel.ITypeDescriptorContext" /> that provides a format context.</param>
/// <param name="destinationType">The type to convert to.</param>
/// <returns><see langword="true" /> if this converter can perform the conversion; otherwise, <see langword="false" />.</returns>
public override bool CanConvertTo(ITypeDescriptorContext? context, [NotNullWhen(true)] Type? destinationType)
{
return destinationType == typeof(InstanceDescriptor) || base.CanConvertTo(context, destinationType);
Expand All @@ -36,6 +41,10 @@ public override bool CanConvertTo(ITypeDescriptorContext? context, [NotNullWhen(
/// <summary>
/// Converts the given value object to a <see cref='System.DateOnly'/> object.
/// </summary>
/// <param name="context">An <see cref="T:System.ComponentModel.ITypeDescriptorContext" /> that provides a format context.</param>
/// <param name="culture">An optional <see cref="T:System.Globalization.CultureInfo" />. If not supplied, the current culture is assumed.</param>
/// <param name="value">The <see cref="T:System.Object" /> to convert.</param>
/// <returns>An <see cref="T:System.Object" /> that represents the converted <paramref name="value" />.</returns>
public override object? ConvertFrom(ITypeDescriptorContext? context, CultureInfo? culture, object value)
{
if (value is string text)
Expand Down Expand Up @@ -77,6 +86,11 @@ public override bool CanConvertTo(ITypeDescriptorContext? context, [NotNullWhen(
/// <summary>
/// Converts the given value object from a <see cref='System.DateOnly'/> object using the arguments.
/// </summary>
/// <param name="context">An <see cref="T:System.ComponentModel.ITypeDescriptorContext" /> that provides a format context.</param>
/// <param name="culture">An optional <see cref="T:System.Globalization.CultureInfo" />. If not supplied, the current culture is assumed.</param>
/// <param name="value">The <see cref="T:System.Object" /> to convert.</param>
/// <param name="destinationType">The <see cref="T:System.Type" /> to convert the value to.</param>
/// <returns>An <see cref="T:System.Object" /> that represents the converted <paramref name="value" />.</returns>
public override object? ConvertTo(ITypeDescriptorContext? context, CultureInfo? culture, object? value, Type destinationType)
{
if (destinationType == typeof(string) && value is DateOnly dateOnly)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
namespace System.ComponentModel
{
/// <summary>
/// Provides a type converter to convert <see cref='System.TimeOnly'/>
/// objects to and from various other representations.
/// Provides a type converter to convert <see cref='System.TimeOnly'/> objects to and from various other representations.
/// </summary>
public class TimeOnlyConverter : TypeConverter
{
Expand All @@ -19,6 +18,9 @@ public class TimeOnlyConverter : TypeConverter
/// object in the given source type to a <see cref='System.TimeOnly'/>
/// object using the specified context.
/// </summary>
/// <param name="context">An <see cref="T:System.ComponentModel.ITypeDescriptorContext" /> that provides a format context.</param>
/// <param name="sourceType">The type to convert from.</param>
/// <returns><see langword="true" /> if this object can perform the conversion; otherwise, <see langword="false" />.</returns>
public override bool CanConvertFrom(ITypeDescriptorContext? context, Type sourceType)
{
return sourceType == typeof(string) || base.CanConvertFrom(context, sourceType);
Expand All @@ -28,6 +30,9 @@ public override bool CanConvertFrom(ITypeDescriptorContext? context, Type source
/// Gets a value indicating whether this converter can convert an object
/// to the given destination type using the context.
/// </summary>
/// <param name="context">An <see cref="T:System.ComponentModel.ITypeDescriptorContext" /> that provides a format context.</param>
/// <param name="destinationType">The type to convert to.</param>
/// <returns><see langword="true" /> if this converter can perform the conversion; otherwise, <see langword="false" />.</returns>
public override bool CanConvertTo(ITypeDescriptorContext? context, [NotNullWhen(true)] Type? destinationType)
{
return destinationType == typeof(InstanceDescriptor) || base.CanConvertTo(context, destinationType);
Expand All @@ -36,6 +41,10 @@ public override bool CanConvertTo(ITypeDescriptorContext? context, [NotNullWhen(
/// <summary>
/// Converts the given value object to a <see cref='System.TimeOnly'/> object.
/// </summary>
/// <param name="context">An <see cref="T:System.ComponentModel.ITypeDescriptorContext" /> that provides a format context.</param>
/// <param name="culture">An optional <see cref="T:System.Globalization.CultureInfo" />. If not supplied, the current culture is assumed.</param>
/// <param name="value">The <see cref="T:System.Object" /> to convert.</param>
/// <returns>An <see cref="T:System.Object" /> that represents the converted <paramref name="value" />.</returns>
public override object? ConvertFrom(ITypeDescriptorContext? context, CultureInfo? culture, object value)
{
if (value is string text)
Expand Down Expand Up @@ -77,6 +86,11 @@ public override bool CanConvertTo(ITypeDescriptorContext? context, [NotNullWhen(
/// <summary>
/// Converts the given value object from a <see cref='System.TimeOnly'/> object using the arguments.
/// </summary>
/// <param name="context">An <see cref="T:System.ComponentModel.ITypeDescriptorContext" /> that provides a format context.</param>
/// <param name="culture">An optional <see cref="T:System.Globalization.CultureInfo" />. If not supplied, the current culture is assumed.</param>
/// <param name="value">The <see cref="T:System.Object" /> to convert.</param>
/// <param name="destinationType">The <see cref="T:System.Type" /> to convert the value to.</param>
/// <returns>An <see cref="T:System.Object" /> that represents the converted <paramref name="value" />.</returns>
public override object? ConvertTo(ITypeDescriptorContext? context, CultureInfo? culture, object? value, Type destinationType)
{
if (destinationType == typeof(string) && value is TimeOnly timeOnly)
Expand Down