28 lines
763 B
C#
Executable File
28 lines
763 B
C#
Executable File
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Opsoft.NetCore.O3App.Shared;
|
|
|
|
namespace Opsoft.NetCore.O3App.Infrastructure
|
|
{
|
|
[MapTo(typeof(IMapper), ServiceLifetime.Singleton)]
|
|
public class ObjectMapper : IMapper
|
|
{
|
|
private readonly AutoMapper.IMapper mapper;
|
|
|
|
public ObjectMapper(AutoMapper.IMapper mapper)
|
|
{
|
|
this.mapper = Guard.ArgumentNotNull(mapper, nameof(mapper));
|
|
}
|
|
|
|
public TDestination Map<TDestination>(object source)
|
|
{
|
|
return mapper.Map<TDestination>(source);
|
|
}
|
|
|
|
public TDestination Map<TSource, TDestination>(TSource source, TDestination destination)
|
|
{
|
|
return mapper.Map(source, destination);
|
|
}
|
|
}
|
|
}
|