AutoMapping.cs 856 B

123456789101112131415161718192021222324252627282930313233
  1. using AutoMapper;
  2. using System;
  3. namespace WingServerCommon.Mapper
  4. {
  5. public class AutoMapping
  6. {
  7. /// <summary>
  8. /// Auto mapper instance
  9. /// </summary>
  10. public static IMapper MapperInstance { get; set; }
  11. private AutoMapping() { }
  12. static AutoMapping()
  13. {
  14. var config = new MapperConfiguration(cfg =>
  15. {
  16. cfg.AddMaps(AppDomain.CurrentDomain.GetAssemblies());
  17. });
  18. MapperInstance = new AutoMapper.Mapper(config);
  19. }
  20. public static bool LoadAutoMapping()
  21. {
  22. var config = new MapperConfiguration(cfg =>
  23. {
  24. cfg.AddMaps(AppDomain.CurrentDomain.GetAssemblies());
  25. });
  26. MapperInstance = new AutoMapper.Mapper(config);
  27. return true;
  28. }
  29. }
  30. }