VAutoMapperConfiguration.cs 696 B

1234567891011121314151617181920212223
  1. using AutoMapper;
  2. using AutoMapper.Configuration;
  3. using System;
  4. namespace VCommon.VAutoMapper.Internals
  5. {
  6. internal class VAutoMapperConfiguration
  7. {
  8. public MapperConfigurationExpression AutoMapperConfiguration { get; } = new MapperConfigurationExpression();
  9. public IConfigurationProvider Config { get; private set; }
  10. public IMapper Mapper { get; private set; }
  11. public IMappingExpression CreateMap(Type s, Type d) => AutoMapperConfiguration.CreateMap(s, d, MemberList.Source);
  12. public void FlushMapper()
  13. {
  14. Config = new MapperConfiguration(AutoMapperConfiguration);
  15. Mapper = new Mapper(Config);
  16. }
  17. }
  18. }