Notes to Implementers
public override bool AcceptsNull { get; }
Public Overrides ReadOnly Property AcceptsNull As Boolean
Get
public:
virtual property bool AcceptsNull {
bool get () override;
}
abstract AcceptsNull : bool with get
override AcceptsNull : bool with get
The behavior is equivalent to the behavior of the AllowNullAttribute: Even if the converters DataType doesn't allow null values, null will be accepted as input if the AcceptsNull property is true.
Writing an own implementation of TypeConverterT is easy:
using FolkerKinzel.CsvTools.Mappings.TypeConverters;
using System.Globalization;
namespace Examples;
/// <summary>
/// Example implementation of <see cref="TypeConverter{T}"/> for the
/// <see cref="Int128"/> struct.
/// </summary>
public sealed class Int128Converter() : TypeConverter<Int128>(true, default)
{
public override bool AcceptsNull => false;
public override string? ConvertToString(Int128 value)
=> value.ToString(null, CultureInfo.InvariantCulture);
public override bool TryParse(ReadOnlySpan<char> value, out Int128 result)
=> Int128.TryParse(value, out result);
}