@ -9,7 +9,6 @@ using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Data ;
using Volo.Abp.Data ;
using Volo.Abp.ObjectExtending ;
using Volo.Abp.ObjectExtending ;
using Volo.Abp.ObjectMapping ;
using Volo.Abp.ObjectMapping ;
using Volo.Abp.Reflection ;
namespace Volo.Abp.Mapperly ;
namespace Volo.Abp.Mapperly ;
@ -62,8 +61,7 @@ public class MapperlyAutoObjectMappingProvider : IAutoObjectMappingProvider
return destination ;
return destination ;
}
}
throw new AbpException ( $"No {TypeHelper.GetFullNameHandlingNullableAndGenerics(typeof(IAbpMapperlyMapper<TSource, TDestination>))} or" +
throw GetNoMapperFoundException < TSource , TDestination > ( ) ;
$" {TypeHelper.GetFullNameHandlingNullableAndGenerics(typeof(IAbpReverseMapperlyMapper<TSource, TDestination>))} was found" ) ;
}
}
public virtual TDestination Map < TSource , TDestination > ( TSource source , TDestination destination )
public virtual TDestination Map < TSource , TDestination > ( TSource source , TDestination destination )
@ -95,8 +93,34 @@ public class MapperlyAutoObjectMappingProvider : IAutoObjectMappingProvider
return destination ;
return destination ;
}
}
throw new AbpException ( $"No {TypeHelper.GetFullNameHandlingNullableAndGenerics(typeof(IAbpMapperlyMapper<TSource, TDestination>))} or" +
throw GetNoMapperFoundException < TSource , TDestination > ( ) ;
$" {TypeHelper.GetFullNameHandlingNullableAndGenerics(typeof(IAbpReverseMapperlyMapper<TSource, TDestination>))} was found" ) ;
}
protected virtual AbpException GetNoMapperFoundException < TSource , TDestination > ( )
{
var newLine = Environment . NewLine ;
var message = "No object mapping was found for the specified source and destination types." +
newLine +
newLine +
"Mapping attempted:" +
newLine +
$"{typeof(TSource).Name} -> {typeof(TDestination).Name}" +
newLine +
$"{typeof(TSource).FullName} -> {typeof(TDestination).FullName}" +
newLine +
newLine +
"How to fix:" +
newLine +
"Define a mapping class for these types:" +
newLine +
" - Use MapperBase<TSource, TDestination> for one-way mapping." +
newLine +
" - Use TwoWayMapperBase<TDestination, TSource> for two-way mapping." +
newLine +
newLine +
"For details, see the Mapperly integration document https://abp.io/docs/latest/framework/infrastructure/object-to-object-mapping#mapperly-integration" ;
return new AbpException ( message ) ;
}
}
protected virtual bool TryToMapCollection < TSource , TDestination > ( TSource source , TDestination ? destination , out TDestination collectionResult )
protected virtual bool TryToMapCollection < TSource , TDestination > ( TSource source , TDestination ? destination , out TDestination collectionResult )