generated from Avanade/avanade-template
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathAutoMapperWrapper.cs
25 lines (21 loc) · 1.29 KB
/
AutoMapperWrapper.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// Copyright (c) Avanade. Licensed under the MIT License. See https://github.com/Avanade/CoreEx
namespace CoreEx.Mapping
{
/// <summary>
/// Represents an <see cref="AutoMapper.IMapper"/> wrapper to enable <i>CoreEx</i> <see cref="IMapper"/>.
/// </summary>
/// <param name="autoMapper">The <see cref="AutoMapper.IMapper"/> being wrapped.</param>
public class AutoMapperWrapper(AutoMapper.IMapper autoMapper) : IMapper
{
/// <summary>
/// Gets the wrapped <see cref="AutoMapper.IMapper"/>
/// </summary>
public AutoMapper.IMapper Mapper { get; } = autoMapper.ThrowIfNull(nameof(autoMapper));
/// <inheritdoc/>
public TDestination? Map<TDestination>(object? source, OperationTypes operationType = OperationTypes.Unspecified) => Mapper.Map<TDestination>(source!, operationType);
/// <inheritdoc/>
public TDestination? Map<TSource, TDestination>(TSource? source, OperationTypes operationType = OperationTypes.Unspecified) => Mapper.Map<TSource, TDestination>(source!, operationType);
/// <inheritdoc/>
public TDestination? Map<TSource, TDestination>(TSource? source, TDestination? destination, OperationTypes operationType = OperationTypes.Unspecified) => Mapper.Map(source, destination, operationType);
}
}