Class CsvConverterAttribute
- Namespace
- FlameCsv.Attributes
- Assembly
- FlameCsv.Core.dll
Base attribute for overriding converters for the target member or parameter.
[AttributeUsage(AttributeTargets.Property|AttributeTargets.Field|AttributeTargets.Parameter)]
public abstract class CsvConverterAttribute : Attribute
- Inheritance
-
CsvConverterAttribute
- Derived
-
CsvConverterAttribute<TConverter>
Remarks
The resulting converter is cast to CsvConverter<T, TValue>.
This attribute is not recognized by the source generator,
use CsvConverterAttribute<TConverter> instead.
Methods
TryCreateConverterOrFactory<T>(Type, CsvOptions<T>, out CsvConverter<T>?)
Attempts to create a converter for the target member or parameter.
If the configured converter is not for token type T
, this method should return false
.
If the converter is not for the target type, this method should throw a CsvConfigurationException.
protected abstract bool TryCreateConverterOrFactory<T>(Type targetType, CsvOptions<T> options, out CsvConverter<T>? converter) where T : unmanaged, IBinaryInteger<T>
Parameters
targetType
TypeType to convert
options
CsvOptions<T>Current configuration instance
converter
CsvConverter<T>
Returns
- bool
Converter instance
Type Parameters
T
Exceptions
- CsvConfigurationException
Thrown if
targetType
is not valid for the member, or is not present in the configuration and has no parameterless constructor.
TryCreateConverter<T>(Type, CsvOptions<T>, out CsvConverter<T>?)
Creates the configured converter.
[RequiresDynamicCode("This code path may require types that cannot be statically analyzed and might need runtime code generation. Use the source generator APIs for native AOT applications.")]
[RequiresUnreferencedCode("This code path may require types that cannot be statically analyzed and might need runtime code generation. Use the source generator APIs for native AOT applications.")]
public bool TryCreateConverter<T>(Type targetType, CsvOptions<T> options, out CsvConverter<T>? converter) where T : unmanaged, IBinaryInteger<T>
Parameters
targetType
Typeoptions
CsvOptions<T>converter
CsvConverter<T>
Returns
Type Parameters
T