Interface IUmbracoMapper
Provides object-to-object mapping functionality for Umbraco.
Namespace: Umbraco.Cms.Core.Mapping
Assembly: Umbraco.Core.dll
Syntax
public interface IUmbracoMapper
Remarks
The mapper supports defining custom mappings between types, including constructors and mapping methods. It can map single objects, map to existing objects, and map enumerables of objects.
Methods
View SourceDefine<TSource, TTarget>()
Defines a mapping.
Declaration
void Define<TSource, TTarget>()
Type Parameters
| Name | Description |
|---|---|
| TSource | The source type. |
| TTarget | The target type. |
Define<TSource, TTarget>(Action<TSource, TTarget, MapperContext>)
Defines a mapping.
Declaration
void Define<TSource, TTarget>(Action<TSource, TTarget, MapperContext> map)
Parameters
| Type | Name | Description |
|---|---|---|
| Action<TSource, TTarget, MapperContext> | map | A mapping method. |
Type Parameters
| Name | Description |
|---|---|
| TSource | The source type. |
| TTarget | The target type. |
Define<TSource, TTarget>(Func<TSource, MapperContext, TTarget>)
Defines a mapping.
Declaration
void Define<TSource, TTarget>(Func<TSource, MapperContext, TTarget> ctor)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<TSource, MapperContext, TTarget> | ctor | A constructor method. |
Type Parameters
| Name | Description |
|---|---|
| TSource | The source type. |
| TTarget | The target type. |
Define<TSource, TTarget>(Func<TSource, MapperContext, TTarget>, Action<TSource, TTarget, MapperContext>)
Defines a mapping.
Declaration
void Define<TSource, TTarget>(Func<TSource, MapperContext, TTarget> ctor, Action<TSource, TTarget, MapperContext> map)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<TSource, MapperContext, TTarget> | ctor | A constructor method. Will not be used if the mapping call receives a Target object |
| Action<TSource, TTarget, MapperContext> | map | A mapping method. |
Type Parameters
| Name | Description |
|---|---|
| TSource | The source type. |
| TTarget | The target type. |
MapEnumerable<TSourceElement, TTargetElement>(IEnumerable<TSourceElement>)
Maps an enumerable of source objects to a new list of target objects.
Declaration
List<TTargetElement> MapEnumerable<TSourceElement, TTargetElement>(IEnumerable<TSourceElement> source)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<TSourceElement> | source | The source objects. |
Returns
| Type | Description |
|---|---|
| List<TTargetElement> | A list containing the target objects. |
Type Parameters
| Name | Description |
|---|---|
| TSourceElement | The type of the source objects. |
| TTargetElement | The type of the target objects. |
MapEnumerable<TSourceElement, TTargetElement>(IEnumerable<TSourceElement>, Action<MapperContext>)
Maps an enumerable of source objects to a new list of target objects.
Declaration
List<TTargetElement> MapEnumerable<TSourceElement, TTargetElement>(IEnumerable<TSourceElement> source, Action<MapperContext> f)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<TSourceElement> | source | The source objects. |
| Action<MapperContext> | f | A mapper context preparation method. |
Returns
| Type | Description |
|---|---|
| List<TTargetElement> | A list containing the target objects. |
Type Parameters
| Name | Description |
|---|---|
| TSourceElement | The type of the source objects. |
| TTargetElement | The type of the target objects. |
MapEnumerable<TSourceElement, TTargetElement>(IEnumerable<TSourceElement>, MapperContext)
Maps an enumerable of source objects to a new list of target objects.
Declaration
List<TTargetElement> MapEnumerable<TSourceElement, TTargetElement>(IEnumerable<TSourceElement> source, MapperContext context)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<TSourceElement> | source | The source objects. |
| MapperContext | context | A mapper context. |
Returns
| Type | Description |
|---|---|
| List<TTargetElement> | A list containing the target objects. |
Type Parameters
| Name | Description |
|---|---|
| TSourceElement | The type of the source objects. |
| TTargetElement | The type of the target objects. |
Map<TTarget>(object?)
Maps a source object to a new target object.
Declaration
TTarget? Map<TTarget>(object? source)
Parameters
| Type | Name | Description |
|---|---|---|
| object | source | The source object. |
Returns
| Type | Description |
|---|---|
| TTarget | The target object. |
Type Parameters
| Name | Description |
|---|---|
| TTarget | The target type. |
Map<TTarget>(object?, Action<MapperContext>)
Maps a source object to a new target object.
Declaration
TTarget? Map<TTarget>(object? source, Action<MapperContext> f)
Parameters
| Type | Name | Description |
|---|---|---|
| object | source | The source object. |
| Action<MapperContext> | f | A mapper context preparation method. |
Returns
| Type | Description |
|---|---|
| TTarget | The target object. |
Type Parameters
| Name | Description |
|---|---|
| TTarget | The target type. |
Map<TTarget>(object?, MapperContext)
Maps a source object to a new target object.
Declaration
TTarget? Map<TTarget>(object? source, MapperContext context)
Parameters
| Type | Name | Description |
|---|---|---|
| object | source | The source object. |
| MapperContext | context | A mapper context. |
Returns
| Type | Description |
|---|---|
| TTarget | The target object. |
Type Parameters
| Name | Description |
|---|---|
| TTarget | The target type. |
Map<TSource, TTarget>(TSource?)
Maps a source object to a new target object.
Declaration
TTarget? Map<TSource, TTarget>(TSource? source)
Parameters
| Type | Name | Description |
|---|---|---|
| TSource | source | The source object. |
Returns
| Type | Description |
|---|---|
| TTarget | The target object. |
Type Parameters
| Name | Description |
|---|---|
| TSource | The source type. |
| TTarget | The target type. |
Map<TSource, TTarget>(TSource, Action<MapperContext>)
Maps a source object to a new target object.
Declaration
TTarget? Map<TSource, TTarget>(TSource source, Action<MapperContext> f)
Parameters
| Type | Name | Description |
|---|---|---|
| TSource | source | The source object. |
| Action<MapperContext> | f | A mapper context preparation method. |
Returns
| Type | Description |
|---|---|
| TTarget | The target object. |
Type Parameters
| Name | Description |
|---|---|
| TSource | The source type. |
| TTarget | The target type. |
Map<TSource, TTarget>(TSource?, MapperContext)
Maps a source object to a new target object.
Declaration
TTarget? Map<TSource, TTarget>(TSource? source, MapperContext context)
Parameters
| Type | Name | Description |
|---|---|---|
| TSource | source | The source object. |
| MapperContext | context | A mapper context. |
Returns
| Type | Description |
|---|---|
| TTarget | The target object. |
Type Parameters
| Name | Description |
|---|---|
| TSource | The source type. |
| TTarget | The target type. |
Map<TSource, TTarget>(TSource, TTarget)
Maps a source object to an existing target object.
Declaration
TTarget Map<TSource, TTarget>(TSource source, TTarget target)
Parameters
| Type | Name | Description |
|---|---|---|
| TSource | source | The source object. |
| TTarget | target | The target object. |
Returns
| Type | Description |
|---|---|
| TTarget | The target object. |
Type Parameters
| Name | Description |
|---|---|
| TSource | The source type. |
| TTarget | The target type. |
Map<TSource, TTarget>(TSource, TTarget, Action<MapperContext>)
Maps a source object to an existing target object.
Declaration
TTarget Map<TSource, TTarget>(TSource source, TTarget target, Action<MapperContext> f)
Parameters
| Type | Name | Description |
|---|---|---|
| TSource | source | The source object. |
| TTarget | target | The target object. |
| Action<MapperContext> | f | A mapper context preparation method. |
Returns
| Type | Description |
|---|---|
| TTarget | The target object. |
Type Parameters
| Name | Description |
|---|---|
| TSource | The source type. |
| TTarget | The target type. |
Map<TSource, TTarget>(TSource, TTarget, MapperContext)
Maps a source object to an existing target object.
Declaration
TTarget Map<TSource, TTarget>(TSource source, TTarget target, MapperContext context)
Parameters
| Type | Name | Description |
|---|---|---|
| TSource | source | The source object. |
| TTarget | target | The target object. |
| MapperContext | context | A mapper context. |
Returns
| Type | Description |
|---|---|
| TTarget | The target object. |
Type Parameters
| Name | Description |
|---|---|
| TSource | The source type. |
| TTarget | The target type. |