MappingConversionType
Namespace: Riok.Mapperly.Abstractions
A MappingConversionType represents a type of conversion how one type can be converted into another.
public enum MappingConversionType
Inheritance Object → ValueType → Enum → MappingConversionType
Implements IComparable, ISpanFormattable, IFormattable, IConvertible
Attributes FlagsAttribute
Fields
Name | Value | Description |
---|---|---|
None | 0 | None. |
Constructor | 1 | Use the constructor of the target type, which accepts the source type as a single parameter. |
ImplicitCast | 2 | An implicit cast from the source type to the target type. |
ExplicitCast | 4 | An explicit cast from the source type to the target type. |
ParseMethod | 8 | If the source type is a String, uses a static visible method named Parse on the target type with a return type equal to the target type and a string as single parameter. |
ToStringMethod | 16 | If the target type is a String, uses the ToString method on the source type. |
StringToEnum | 32 | If the target is an Enum and the source is a String, parses the string to match the name of an enum member. |
EnumToString | 64 | If the source is an Enum and the target is a String, uses the name of the enum member to convert it to a string. |
EnumToEnum | 128 | If the source is an Enum and the target is another Enum, map it according to the EnumMappingStrategy. |
DateTimeToDateOnly | 256 | If the source is a DateTime and the target is a DateOnly uses the FromDateTime method on the target type with the source as single parameter. |
DateTimeToTimeOnly | 512 | If the source is a DateTime and the target is a TimeOnly uses the FromDateTime method on the target type with the source as single parameter. |
Queryable | 1024 | If the source and the target are a . Only uses object initializers and inlines the mapping code. |
Enumerable | 2048 | If the source and the target are an IEnumerable<T> Maps each element individually. |
Dictionary | 4096 | If the source and targets are IDictionary<TKey, TValue> or IReadOnlyDictionary<TKey, TValue>. Maps each KeyValuePair<TKey, TValue> individually. |
Span | 8192 | If the source or target is a Span<T> or ReadOnlySpan<T> Maps each element individually. |
Memory | 16384 | If the source or target is a Memory<T> or ReadOnlyMemory<T> Maps each element individually. |
Tuple | 32768 | If the target is a ValueTuple<T1, T2> or tuple expression (A: 10, B: 12). Supports positional and named mapping. Only uses ValueTuple<T1, T2> in . |
EnumUnderlyingType | 65536 | Allow using the underlying type of enum to map from or to an enum type. |
ToTargetMethod | 131072 | If the source type contains a ToTarget method other than ToString , use it |
StaticConvertMethods | 262144 | If the source type contains a static ToTarget method or the target type contains a static methods Create(TSource) , CreateFrom(TSource) , CreateFromTSource(TSource) , From(TSource) , FromTSource(TSource) or similar methods with keyword, use it. The exception is DateTime conversions, which are enabled by separate options (MappingConversionType.DateTimeToTimeOnly, MappingConversionType.DateTimeToDateOnly). |
All | -1 | Enables all supported conversions. |