You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
abp/src/Volo.Abp.AutoMapper/Volo/Abp/AutoMapper/AutoMapperObjectMapper.cs

31 lines
902 B

using System;
using AutoMapper;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.ObjectMapping;
using Volo.DependencyInjection;
namespace Volo.Abp.AutoMapper
{
[Dependency(ServiceLifetime.Transient, ReplaceServices = true)]
public class AutoMapperObjectMapper : DefaultObjectMapper
{
private readonly IMapper _mapper;
public AutoMapperObjectMapper(IMapperAccessor mapper, IServiceProvider serviceProvider)
: base(serviceProvider)
{
_mapper = mapper.Mapper;
}
protected override TDestination AutoMap<TSource, TDestination>(object source)
{
return _mapper.Map<TDestination>(source);
}
protected override TDestination AutoMap<TSource, TDestination>(TSource source, TDestination destination)
{
return _mapper.Map(source, destination);
}
}
}