2020-08-08 08:53:35 +02:00
|
|
|
|
namespace Giants.Services
|
|
|
|
|
{
|
|
|
|
|
using AutoMapper;
|
2020-08-16 11:03:10 +02:00
|
|
|
|
using Giants.DataContract.V1;
|
2020-08-08 08:53:35 +02:00
|
|
|
|
|
|
|
|
|
public static class Mapper
|
|
|
|
|
{
|
|
|
|
|
public static IMapper Instance { get; private set; }
|
|
|
|
|
|
|
|
|
|
private static readonly object LockObject = new object();
|
|
|
|
|
|
|
|
|
|
public static IMapper GetMapper()
|
|
|
|
|
{
|
|
|
|
|
if (Instance == null)
|
|
|
|
|
{
|
|
|
|
|
lock(LockObject)
|
|
|
|
|
{
|
|
|
|
|
if (Instance == null)
|
|
|
|
|
{
|
|
|
|
|
var config = new MapperConfiguration(cfg => {
|
2020-08-16 11:03:10 +02:00
|
|
|
|
cfg.CreateMap<DataContract.V1.ServerInfo, ServerInfo>();
|
|
|
|
|
cfg.CreateMap<ServerInfo, DataContract.V1.ServerInfo>();
|
|
|
|
|
cfg.CreateMap<ServerInfo, ServerInfoWithHostAddress>();
|
|
|
|
|
cfg.CreateMap<VersionInfo, DataContract.V1.VersionInfo>();
|
2020-08-08 08:53:35 +02:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Instance = new AutoMapper.Mapper(config);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Instance;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|