Table of Contents

Class TypeMapper

Namespace
LfrlAnvil.Mapping
Assembly
LfrlAnvil.Mapping.dll

Represents an object capable of mapping objects to different types.

public sealed class TypeMapper : ITypeMapper
Inheritance
TypeMapper
Implements
Inherited Members
Extension Methods

Methods

GetConfiguredMappings()

Returns all defined (source-type, destination-type) mappings.

[Pure]
public IEnumerable<TypeMappingKey> GetConfiguredMappings()

Returns

IEnumerable<TypeMappingKey>

All defined (source-type, destination-type) mappings.

IsConfigured(Type, Type)

Checks whether or not the mapping definition from sourceType to destinationType exists.

[Pure]
public bool IsConfigured(Type sourceType, Type destinationType)

Parameters

sourceType Type

Source type.

destinationType Type

Destination type.

Returns

bool

true when mapping definition exists, otherwise false.

TryMap(Type, object, out object)

Attempts to map the provided source to the desired destinationType type.

public bool TryMap(Type destinationType, object source, out object result)

Parameters

destinationType Type

Desired destination type.

source object

Source object.

result object

out parameter that returns source mapped to the destinationType type if mapping was successful.

Returns

bool

true when mapping was successful, otherwise false.

TryMapMany<TSource, TDestination>(IEnumerable<TSource>, out IEnumerable<TDestination>)

Attempts to map the provided source collection with elements of TSource type to a collection with elements of the desired TDestination type.

public bool TryMapMany<TSource, TDestination>(IEnumerable<TSource> source, out IEnumerable<TDestination> result)

Parameters

source IEnumerable<TSource>

Source collection.

result IEnumerable<TDestination>

out parameter that returns source collection mapped to collection with elements of the TDestination type if mapping was successful.

Returns

bool

true when mapping was successful, otherwise false.

Type Parameters

TSource

Source collection's element type.

TDestination

Desired destination collection's element type.

TryMap<TDestination>(object, out TDestination)

Attempts to map the provided source to the desired TDestination type.

public bool TryMap<TDestination>(object source, out TDestination result)

Parameters

source object

Source object.

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.

TryMap<TSource, TDestination>(TSource, out TDestination)

Attempts to map the provided source of TSource type to the desired TDestination type.

public bool TryMap<TSource, TDestination>(TSource source, out TDestination result)

Parameters

source TSource

Source object.

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

TSource

Source object type.

TDestination

Desired destination type.