Note
In the following code examples - for easier
readability - exception handling has been omitted.
public sealed class CharConverter : TypeConverter<char>
Public NotInheritable Class CharConverter
Inherits TypeConverter(Of Char)
public ref class CharConverter sealed : public TypeConverter<wchar_t>
[<SealedAttribute>]
type CharConverter =
class
inherit TypeConverter<char>
end
Object serialization with CSV:
using FolkerKinzel.CsvTools;
using FolkerKinzel.CsvTools.Mappings;
using FolkerKinzel.CsvTools.Mappings.TypeConverters;
namespace Benchmarks;
internal static partial class CalculationWriter
{
internal static string WriteDefault(Calculation[] data)
{
var doubleConverter = new DoubleConverter();
CsvMapping mapping = CsvMappingBuilder
.Create()
.AddProperty("First", doubleConverter)
.AddProperty("Operator", new CharConverter())
.AddProperty("Second", doubleConverter)
.AddProperty("Result", doubleConverter)
.Build();
return data.ToCsv(
mapping,
static (calculation, mapping) =>
{
mapping.First = calculation.First;
mapping.Operator = calculation.Operator;
mapping.Second = calculation.Second;
mapping.Result = calculation.Result;
});
}
}
CharConverter | TypeConverterT implementation for Char. |
AcceptsNull |
Gets a value indicating whether the converter accepts
null references as input.
(Overrides TypeConverterTAcceptsNull) |
DataType |
The data type the converter converts.
(Inherited from TypeConverterT) |
DefaultValue |
Gets the value to return if the parser finds no data in the CSV,
or if parsing fails and
the Throwing property is false.
(Inherited from TypeConverterT) |
Throwing |
Gets a value indicating whether the converter throws a
FormatException
when a parsing error occurs, or if it returns
DefaultValue value instead.
(Inherited from TypeConverterT) |
ConvertToString |
Converts value to a String or null.
(Overrides TypeConverterTConvertToString(T)) |
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object) |
GetHashCode | Serves as the default hash function. (Inherited from Object) |
GetType | Gets the Type of the current instance. (Inherited from Object) |
Parse |
Parses a read-only span of characters and returns
the corresponding .NET object.
(Inherited from TypeConverterT) |
ToString | Returns a string that represents the current object. (Inherited from Object) |
TryParse |
Tries to parse a read-only span of characters as a T value.
(Overrides TypeConverterTTryParse(ReadOnlySpanChar, T)) |