CostCalculationItem/IRaCIS.Core.Application/AutoMapper/AutoMapperConfig.cs

33 lines
1.3 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using AutoMapper;
namespace IRaCIS.Application.AutoMapper
{
public class AutoMapperConfig
{
public static void Config()
{
//Mapper.Initialize(cfg =>
//{
// cfg.AddProfile<DomainToViewModelMappingProfile>();
// cfg.AddProfile(new ViewModelToDomainMappingProfile());
// cfg.AddProfile(new LogicChangeMappingProfile());
// cfg.ForAllMaps((a, b) => b.ForAllMembers(opt => opt.Condition((src, dest, sourceMember) => sourceMember != null)));
//});
}
public static MapperConfiguration RegisterMappings()
{
//创建AutoMapperConfiguration, 提供静态方法Configure一次加载所有层中Profile定义
//MapperConfiguration实例可以静态存储在一个静态字段中也可以存储在一个依赖注入容器中。 一旦创建,不能更改/修改。
return new MapperConfiguration(cfg =>
{
cfg.AddProfile<DomainToViewModelMappingProfile>();
cfg.AddProfile(new ViewModelToDomainMappingProfile());
cfg.AddProfile(new LogicChangeMappingProfile());
cfg.ForAllMaps((a, b) => b.ForAllMembers(opt => opt.Condition((src, dest, sourceMember) => sourceMember != null)));
});
}
}
}