mirror of https://github.com/abpframework/abp
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.
47 lines
1.4 KiB
47 lines
1.4 KiB
using Microsoft.Extensions.DependencyInjection;
|
|
using Volo.Abp.Modularity;
|
|
using Volo.Abp.TestApp.Domain;
|
|
using Volo.Abp.AutoMapper;
|
|
using Volo.Abp.TestApp.Application;
|
|
using Volo.Abp.TestApp.Application.Dto;
|
|
|
|
namespace Volo.Abp.TestApp
|
|
{
|
|
[DependsOn(typeof(AbpAutoMapperModule))]
|
|
public class TestAppModule : AbpModule
|
|
{
|
|
public override void ConfigureServices(IServiceCollection services)
|
|
{
|
|
ConfigureAutoMapper(services);
|
|
services.AddAssemblyOf<TestAppModule>();
|
|
}
|
|
|
|
public override void OnApplicationInitialization(ApplicationInitializationContext context)
|
|
{
|
|
SeedTestData(context);
|
|
}
|
|
|
|
private static void ConfigureAutoMapper(IServiceCollection services)
|
|
{
|
|
services.Configure<AbpAutoMapperOptions>(options =>
|
|
{
|
|
options.Configurators.Add(ctx =>
|
|
{
|
|
ctx.MapperConfiguration.CreateMap<Person, PersonDto>().ReverseMap();
|
|
ctx.MapperConfiguration.CreateMap<Phone, PhoneDto>().ReverseMap();
|
|
});
|
|
});
|
|
}
|
|
|
|
private static void SeedTestData(ApplicationInitializationContext context)
|
|
{
|
|
using (var scope = context.ServiceProvider.CreateScope())
|
|
{
|
|
scope.ServiceProvider
|
|
.GetRequiredService<TestDataBuilder>()
|
|
.Build();
|
|
}
|
|
}
|
|
}
|
|
}
|