CsvMetadataServices Class
Creates serialization metadata. The code generated for a CsvSerializerContext calls these methods.
public static class CsvMetadataServicesMethods
| Name | Description |
|---|---|
| CreateObjectInfo<T>(CsvSerializerOptions, CsvObjectInfoValues<T>) | Creates the metadata of a type. |
| CreatePropertyInfo<TDeclaring, TValue>(CsvSerializerOptions, CsvPropertyInfoValues<TDeclaring, TValue>) | Creates the metadata of a column. |
| GetConverter<T>(CsvSerializerOptions) | Gets the converter of T: a converter of CsvSerializerOptions.Converters, or a built-in converter. |
| GetConverter<T>(CsvSerializerOptions, CsvConverter<T>?) | Gets the converter of T: a converter of CsvSerializerOptions.Converters, defaultConverter, or a built-in converter. |
| GetEnumConverter<TEnum>() | Gets a converter that reads the names and the numbers of the members of an enumeration, ignoring case, and writes their names. |
| GetNullableConverter<T>(CsvConverter<T>) | Gets a converter of Nullable<T>: an empty value is null, other values are converted by converter. |
| GetSpanParsableConverter<T>() | Gets a converter that parses and formats values with the ISpanParsable<TSelf> and ISpanFormattable implementations of T. |
CreateObjectInfo<T>(CsvSerializerOptions, CsvObjectInfoValues<T>)
CsvMetadataServices.csCreates the metadata of a type.
public static CsvTypeInfo<T> CreateObjectInfo<T>(CsvSerializerOptions options, CsvObjectInfoValues<T> values)Type parameters
T- The type described.
Parameters
optionsCsvSerializerOptions- The options the metadata is created for.
valuesCsvObjectInfoValues<T>- The description of the type.
Returns
CsvTypeInfo<T> The metadata of the type.
CreatePropertyInfo<TDeclaring, TValue>(CsvSerializerOptions, CsvPropertyInfoValues<TDeclaring, TValue>)
CsvMetadataServices.csCreates the metadata of a column.
public static CsvPropertyInfo CreatePropertyInfo<TDeclaring, TValue>(CsvSerializerOptions options, CsvPropertyInfoValues<TDeclaring, TValue> values)Type parameters
TDeclaring- The type that declares the member.
TValue- The type of the member.
Parameters
optionsCsvSerializerOptions- The options the metadata is created for.
valuesCsvPropertyInfoValues<TDeclaring, TValue>- The description of the column.
Returns
CsvPropertyInfo The metadata of the column.
Exceptions
NotSupportedException- No converter converts
TValue.
GetConverter overloads
GetConverter<T>(CsvSerializerOptions)
CsvMetadataServices.csGets the converter of T: a converter of CsvSerializerOptions.Converters, or a built-in converter.
public static CsvConverter<T> GetConverter<T>(CsvSerializerOptions options)Type parameters
T- The type of the values.
Parameters
optionsCsvSerializerOptions- The options.
Returns
CsvConverter<T> The converter.
Exceptions
NotSupportedException- No converter converts
T.
GetConverter<T>(CsvSerializerOptions, CsvConverter<T>?)
CsvMetadataServices.csGets the converter of T: a converter of CsvSerializerOptions.Converters, defaultConverter, or a built-in converter.
public static CsvConverter<T> GetConverter<T>(CsvSerializerOptions options, CsvConverter<T>? defaultConverter)Type parameters
T- The type of the values.
Parameters
optionsCsvSerializerOptions- The options.
defaultConverterCsvConverter<T>?- The converter to use when no converter of the options converts
T, ornullfor the built-in converters.
Returns
CsvConverter<T> The converter.
Exceptions
NotSupportedException- No converter converts
T.
GetEnumConverter<TEnum>()
CsvMetadataServices.csGets a converter that reads the names and the numbers of the members of an enumeration, ignoring case, and writes their names.
public static CsvConverter<TEnum> GetEnumConverter<TEnum>() where TEnum : struct, EnumGetNullableConverter<T>(CsvConverter<T>)
CsvMetadataServices.csGets a converter of Nullable<T>: an empty value is null, other values are converted by converter.
public static CsvConverter<T?> GetNullableConverter<T>(CsvConverter<T> converter) where T : structType parameters
T- The underlying type.
Parameters
converterCsvConverter<T>- The converter of
T.
Returns
CsvConverter<T?> The converter.
GetSpanParsableConverter<T>()
CsvMetadataServices.csGets a converter that parses and formats values with the ISpanParsable<TSelf> and ISpanFormattable implementations of T.
public static CsvConverter<T> GetSpanParsableConverter<T>() where T : ISpanFormattable, ISpanParsable<T>