Browse Source
Optimize the way to get `Map` method through reflection.
Resolve #20820
pull/20829/head
maliming
2 years ago
No known key found for this signature in database
GPG Key ID: A646B9CB645ECEA4
1 changed files with
10 additions and
3 deletions
framework/src/Volo.Abp.ObjectMapping/Volo/Abp/ObjectMapping/DefaultObjectMapper.cs
@ -142,13 +142,20 @@ public class DefaultObjectMapper : IObjectMapper, ITransientDependency
cacheKey ,
_ = >
{
return specificMapper
var method = specificMapper
. GetType ( )
. GetMethods ( )
. First ( x = >
. GetMethods ( BindingFlags . Instance | BindingFlags . Public | BindingFlags . NonPublic )
. FirstOrDefault ( x = >
x . Name = = nameof ( IObjectMapper < object , object > . Map ) & &
x . GetParameters ( ) . Length = = ( destination = = null ? 1 : 2 )
) ;
if ( method = = null )
{
throw new AbpException ( $"Could not find a method named '{nameof(IObjectMapper<object, object>.Map)}' with {(destination == null ? " 1 " : " 2 ")} parameters in the type '{mapperType}'." ) ;
}
return method ;
}
) ;