Table of Contents

Struct TypeMappingContext<TSource>

Namespace
LfrlAnvil.Mapping
Assembly
LfrlAnvil.Mapping.dll

A lightweight generic container for a source object to map.

public readonly struct TypeMappingContext<TSource>

Type Parameters

TSource

Source object type.

Inherited Members

Properties

Source

Source object to map.

public TSource Source { get; }

Property Value

TSource

TypeMapper

Attached ITypeMapper instance.

public ITypeMapper TypeMapper { get; }

Property Value

ITypeMapper

Methods

To<TDestination>()

Maps the Source to the desired TDestination type using the attached TypeMapper instance.

[Pure]
public TDestination To<TDestination>()

Returns

TDestination

Source mapped to the TDestination type.

Type Parameters

TDestination

Desired destination type.

Exceptions

UndefinedTypeMappingException

When mapping from TSource to TDestination is not defined.

TryTo<TDestination>(out TDestination)

Attempts to map the Source to the desired TDestination type using the attached TypeMapper instance.

public bool TryTo<TDestination>(out TDestination result)

Parameters

result TDestination

out parameter that returns Source mapped to the TDestination type if mapping was successful.

Returns

bool

true when mapping was successful, otherwise false.

Type Parameters

TDestination

Desired destination type.