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
destinationType
TypeDesired destination type.
source
objectSource object.
result
objectout parameter that returns
source
mapped to thedestinationType
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 theTDestination
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
objectSource object.
result
TDestinationout parameter that returns
source
mapped to theTDestination
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
TSourceSource object.
result
TDestinationout parameter that returns
source
mapped to theTDestination
type if mapping was successful.
Returns
- bool
true when mapping was successful, otherwise false.
Type Parameters
TSource
Source object type.
TDestination
Desired destination type.