File: System\Windows\Forms\Design\DataMemberFieldConverter.cs
Web Access
Project: src\src\System.Windows.Forms.Design\src\System.Windows.Forms.Design.csproj (System.Windows.Forms.Design)
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
 
using System.ComponentModel;
using System.Globalization;
 
namespace System.Windows.Forms.Design;
 
internal class DataMemberFieldConverter : TypeConverter
{
    public override bool CanConvertFrom(ITypeDescriptorContext? context, Type sourceType) =>
        sourceType == typeof(string) || base.CanConvertFrom(context, sourceType);
 
    public override object? ConvertFrom(ITypeDescriptorContext? context, CultureInfo? culture, object? value)
    {
        return value is not null && value.Equals(SR.None) ? string.Empty : value;
    }
 
    public override object? ConvertTo(ITypeDescriptorContext? context, CultureInfo? culture, object? value, Type destinationType)
    {
        return destinationType == typeof(string) && (value is null || value.Equals(string.Empty))
            ? SR.None_lc
            : base.ConvertTo(context, culture, value, destinationType);
    }
}