2025-03-15 01:39:43 +03:30

20 lines
545 B
C#

using System.Reflection;
using Mapster;
using MapsterMapper;
using Microsoft.Extensions.DependencyInjection;
namespace BuildingBlocks.Mapster;
public static class Extensions
{
public static IServiceCollection AddCustomMapster(this IServiceCollection services, Assembly assembly)
{
var typeAdapterConfig = TypeAdapterConfig.GlobalSettings;
typeAdapterConfig.Scan(assembly);
var mapperConfig = new Mapper(typeAdapterConfig);
services.AddSingleton<IMapper>(mapperConfig);
return services;
}
}