mirror of https://github.com/abpframework/abp.git
2 changed files with 39 additions and 0 deletions
@ -0,0 +1,34 @@ |
|||||
|
using System; |
||||
|
using System.Linq; |
||||
|
using AutoMapper; |
||||
|
using AutoMapper.Internal; |
||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Microsoft.Extensions.DependencyInjection.Extensions; |
||||
|
using Volo.Abp.DependencyInjection; |
||||
|
|
||||
|
namespace Volo.Abp.AutoMapper |
||||
|
{ |
||||
|
public class AbpAutoMapperConventionalRegistrar : ConventionalRegistrarBase |
||||
|
{ |
||||
|
protected readonly Type[] OpenTypes = { |
||||
|
typeof(IValueResolver<,,>), |
||||
|
typeof(IMemberValueResolver<,,,>), |
||||
|
typeof(ITypeConverter<,>), |
||||
|
typeof(IValueConverter<,>), |
||||
|
typeof(IMappingAction<,>) |
||||
|
}; |
||||
|
|
||||
|
public override void AddType(IServiceCollection services, Type type) |
||||
|
{ |
||||
|
if (IsConventionalRegistrationDisabled(type)) |
||||
|
{ |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
if (OpenTypes.Any(type.ImplementsGenericInterface)) |
||||
|
{ |
||||
|
services.TryAddTransient(type); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue