Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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,25 +9,21 @@
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
{
/// <summary>
/// Gets a value indicating whether this converter can convert an
/// object in the given source type to a <see cref='System.DateOnly'/>
/// Gets a value indicating whether this converter can convert an object in the given source type to a <see cref='System.DateOnly'/>
/// object using the specified context.
/// </summary>
/// <inheritdoc />
public override bool CanConvertFrom(ITypeDescriptorContext? context, Type sourceType)
{
return sourceType == typeof(string) || base.CanConvertFrom(context, sourceType);
}

/// <summary>
/// Gets a value indicating whether this converter can convert an object
/// to the given destination type using the context.
/// </summary>
/// <inheritdoc />
public override bool CanConvertTo(ITypeDescriptorContext? context, [NotNullWhen(true)] Type? destinationType)
{
return destinationType == typeof(InstanceDescriptor) || base.CanConvertTo(context, destinationType);
Expand All @@ -36,6 +32,7 @@ public override bool CanConvertTo(ITypeDescriptorContext? context, [NotNullWhen(
/// <summary>
/// Converts the given value object to a <see cref='System.DateOnly'/> object.
/// </summary>
/// <inheritdoc />
public override object? ConvertFrom(ITypeDescriptorContext? context, CultureInfo? culture, object value)
{
if (value is string text)
Expand Down Expand Up @@ -77,6 +74,7 @@ public override bool CanConvertTo(ITypeDescriptorContext? context, [NotNullWhen(
/// <summary>
/// Converts the given value object from a <see cref='System.DateOnly'/> object using the arguments.
/// </summary>
/// <inheritdoc />
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,25 +9,21 @@
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
{
/// <summary>
/// Gets a value indicating whether this converter can convert an
/// object in the given source type to a <see cref='System.TimeOnly'/>
/// Gets a value indicating whether this converter can convert an object in the given source type to a <see cref='System.TimeOnly'/>
/// object using the specified context.
/// </summary>
/// <inheritdoc />
public override bool CanConvertFrom(ITypeDescriptorContext? context, Type sourceType)
{
return sourceType == typeof(string) || base.CanConvertFrom(context, sourceType);
}

/// <summary>
/// Gets a value indicating whether this converter can convert an object
/// to the given destination type using the context.
/// </summary>
/// <inheritdoc />
public override bool CanConvertTo(ITypeDescriptorContext? context, [NotNullWhen(true)] Type? destinationType)
{
return destinationType == typeof(InstanceDescriptor) || base.CanConvertTo(context, destinationType);
Expand All @@ -36,6 +32,7 @@ public override bool CanConvertTo(ITypeDescriptorContext? context, [NotNullWhen(
/// <summary>
/// Converts the given value object to a <see cref='System.TimeOnly'/> object.
/// </summary>
/// <inheritdoc />
public override object? ConvertFrom(ITypeDescriptorContext? context, CultureInfo? culture, object value)
{
if (value is string text)
Expand Down Expand Up @@ -77,6 +74,7 @@ public override bool CanConvertTo(ITypeDescriptorContext? context, [NotNullWhen(
/// <summary>
/// Converts the given value object from a <see cref='System.TimeOnly'/> object using the arguments.
/// </summary>
/// <inheritdoc />
public override object? ConvertTo(ITypeDescriptorContext? context, CultureInfo? culture, object? value, Type destinationType)
{
if (destinationType == typeof(string) && value is TimeOnly timeOnly)
Expand Down