Skip to main content

MapperDefaultsAttribute

Namespace: Riok.Mapperly.Abstractions

Used to set mapper default values in the assembly.

public sealed class MapperDefaultsAttribute : MapperAttribute

Inheritance ObjectAttributeMapperAttributeMapperDefaultsAttribute

Properties

PropertyNameMappingStrategy

Strategy on how to match mapping property names.

public PropertyNameMappingStrategy PropertyNameMappingStrategy { get; set; }

Property Value

PropertyNameMappingStrategy

EnumMappingStrategy

The default enum mapping strategy. Can be overwritten on specific enums via mapping method configurations.

public EnumMappingStrategy EnumMappingStrategy { get; set; }

Property Value

EnumMappingStrategy

EnumMappingIgnoreCase

Whether the case should be ignored for enum mappings.

public bool EnumMappingIgnoreCase { get; set; }

Property Value

Boolean

ThrowOnMappingNullMismatch

Specifies the behaviour in the case when the mapper tries to return null in a mapping method with a non-nullable return type. If set to true an ArgumentNullException is thrown. If set to false the mapper tries to return a default value. For a String this is String.Empty, for value types default and for reference types new() if a parameterless constructor exists or else an ArgumentNullException is thrown.

public bool ThrowOnMappingNullMismatch { get; set; }

Property Value

Boolean

ThrowOnPropertyMappingNullMismatch

Specifies the behaviour in the case when the mapper tries to set a non-nullable property to a null value. If set to true an ArgumentNullException is thrown. If set to false the property assignment is ignored. This is ignored for required init properties and projection mappings.

public bool ThrowOnPropertyMappingNullMismatch { get; set; }

Property Value

Boolean

AllowNullPropertyAssignment

Specifies whether null values are assigned to the target. If true (default), the source is null, and the target does allow null values, null is assigned. If false, null values are never assigned to the target property. This is ignored for required init properties and projection mappings.

public bool AllowNullPropertyAssignment { get; set; }

Property Value

Boolean

UseDeepCloning

Whether to always deep copy objects. Eg. when the type Person[] should be mapped to the same type Person[], when false, the same array is reused. when true, the array and each person is cloned.

public bool UseDeepCloning { get; set; }

Property Value

Boolean

EnabledConversions

Enabled conversions which Mapperly automatically implements. By default all supported type conversions are enabled.

Eg. to disable all automatically implemented conversions:
EnabledConversions = MappingConversionType.None

Eg. to disable ToString() method calls:
EnabledConversions = MappingConversionType.All & ~MappingConversionType.ToStringMethod

public MappingConversionType EnabledConversions { get; set; }

Property Value

MappingConversionType

UseReferenceHandling

Enables the reference handling feature. Disabled by default for performance reasons. When enabled, an IReferenceHandler instance is passed through the mapping methods to keep track of and reuse existing target object instances.

public bool UseReferenceHandling { get; set; }

Property Value

Boolean

IgnoreObsoleteMembersStrategy

The ignore obsolete attribute strategy. Determines how ObsoleteAttribute marked members are mapped. Defaults to IgnoreObsoleteMembersStrategy.None.

public IgnoreObsoleteMembersStrategy IgnoreObsoleteMembersStrategy { get; set; }

Property Value

IgnoreObsoleteMembersStrategy

TypeId

public object TypeId { get; }

Property Value

Object

Constructors

MapperDefaultsAttribute()

public MapperDefaultsAttribute()