Class TypeMapper
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
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
destinationTypeTypeDesired destination type.
sourceobjectSource object.
resultobjectout parameter that returns
sourcemapped to thedestinationTypetype 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
sourceIEnumerable<TSource>Source collection.
resultIEnumerable<TDestination>out parameter that returns
sourcecollection mapped to collection with elements of theTDestinationtype if mapping was successful.
Returns
- bool
true when mapping was successful, otherwise false.
Type Parameters
TSourceSource collection's element type.
TDestinationDesired 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
sourceobjectSource object.
resultTDestinationout parameter that returns
sourcemapped to theTDestinationtype if mapping was successful.
Returns
- bool
true when mapping was successful, otherwise false.
Type Parameters
TDestinationDesired 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
sourceTSourceSource object.
resultTDestinationout parameter that returns
sourcemapped to theTDestinationtype if mapping was successful.
Returns
- bool
true when mapping was successful, otherwise false.
Type Parameters
TSourceSource object type.
TDestinationDesired destination type.