CharConverter Class

TypeConverterT implementation for Char.

Definition

Namespace: FolkerKinzel.CsvTools.Mappings.TypeConverters
Assembly: FolkerKinzel.CsvTools.Mappings (in FolkerKinzel.CsvTools.Mappings.dll) Version: 1.1.0+1263e8243dc2cd78095f678f813d7d9c52ea4315
C#
public sealed class CharConverter : TypeConverter<char>
Inheritance
Object    TypeConverterChar    CharConverter

Example

  Note

In the following code examples - for easier readability - exception handling has been omitted.

Object serialization with CSV:

C#
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;
                   });
    }
}

Constructors

CharConverterTypeConverterT implementation for Char.

Properties

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)

Methods

ConvertToString Converts value to a String or null.
(Overrides TypeConverterTConvertToString(T))
EqualsDetermines whether the specified object is equal to the current object.
(Inherited from Object)
GetHashCodeServes as the default hash function.
(Inherited from Object)
GetTypeGets 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)
ToStringReturns 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))

Extension Methods

ToArrayConverterChar Creates a new array converter instance.
(Defined by TypeConverterExtension)
ToDBNullConverterChar Returns a TypeConverter<> instance that converts and accepts T as well as DBNull.Value. DBNull.Value is the DefaultValue of this TypeConverterT instance.
(Defined by TypeConverterExtension)
ToICollectionConverterChar Creates a new ICollectionT converter instance.
(Defined by TypeConverterExtension)
ToIEnumerableConverterChar Creates a new IEnumerableT converter instance.
(Defined by TypeConverterExtension)
ToIListConverterChar Creates a new IListT converter instance.
(Defined by TypeConverterExtension)
ToIReadOnlyCollectionConverterChar Creates a new IReadOnlyCollectionT converter instance.
(Defined by TypeConverterExtension)
ToIReadOnlyListConverterChar Creates a new IReadOnlyListT converter instance.
(Defined by TypeConverterExtension)
ToListConverterChar Creates a new ListT converter instance.
(Defined by TypeConverterExtension)
ToNullableConverterChar Creates a new NullableT converter instance.
(Defined by TypeConverterExtension)
ToReadOnlyCollectionConverterChar Creates a new ReadOnlyCollectionT converter instance.
(Defined by TypeConverterExtension)

Thread Safety

Static members of this type are safe for multi-threaded operations. Instance members of this type are safe for multi-threaded operations.

See Also