Table of Contents

Method ConstructUsing

Namespace
Mapperion
Assembly
Mapperion.dll

ConstructUsing(Func<TSource, TDestination>)

Builds the destination with the given factory instead of calling a constructor.

IMappingExpression<TSource, TDestination> ConstructUsing(Func<TSource, TDestination> factory)

Parameters

factory Func<TSource, TDestination>

Produces the destination from the source.

Returns

IMappingExpression<TSource, TDestination>

This expression, for chaining.

Remarks

The factory only runs when the destination has to be created. Mapping onto an instance the caller already passed in uses that instance, as it does without a factory. Members are still assigned afterwards, so a factory that fills some of them will see them overwritten by whatever the map resolves for them; ignore those members if the factory is meant to have the last word.

Exceptions

ArgumentNullException

factory is null.

ConstructUsing(Func<TSource, ResolutionContext, TDestination>)

Builds the destination with the given factory, which also receives the running operation so it can map nested values itself.

IMappingExpression<TSource, TDestination> ConstructUsing(Func<TSource, ResolutionContext, TDestination> factory)

Parameters

factory Func<TSource, ResolutionContext, TDestination>

Produces the destination from the source.

Returns

IMappingExpression<TSource, TDestination>

This expression, for chaining.

Exceptions

ArgumentNullException

factory is null.