Is possible to use AutoMapper class in a custom plugin and how ?
Many Thanks
public static IList<TDestination> MapTo<TSource, TDestination>(this IList<TSource> source)
{
Mapper.CreateMap<TSource, TDestination>();
return Mapper.Map<IList<TSource>, IList<TDestination>>(source);
}
public static TDestination MapTo<TSource, TDestination>(this TSource source)
{
Mapper.CreateMap<TSource, TDestination>();
return Mapper.Map<TSource,TDestination>(source);
}
public static class AutoMapperConfiguration
{
private static MapperConfiguration _mapperConfiguration;
private static IMapper _mapper;
/// <summary>
/// Initialize mapper
/// </summary>
public static void Init()
{
_mapperConfiguration = new MapperConfiguration(cfg =>{...});
_mapper = _mapperConfiguration.CreateMapper();
}
public static IMapper Mapper
{
get
{
return _mapper;
}
}
public static MapperConfiguration MapperConfiguration
{
get
{
return _mapperConfiguration;
}
}