mirror of
https://github.com/meysamhadeli/booking-microservices.git
synced 2026-04-12 03:12:11 +08:00
20 lines
545 B
C#
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;
|
|
}
|
|
}
|