28 lines
838 B
C#
28 lines
838 B
C#
using DigitalData.Core.Abstraction.Application.Repository;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
namespace DigitalData.Core.Infrastructure;
|
|
|
|
public class EntityConfigurationOptions<TEntity>
|
|
{
|
|
private readonly IServiceCollection _services;
|
|
|
|
public EntityConfigurationOptions(IServiceCollection services)
|
|
{
|
|
_services = services;
|
|
}
|
|
|
|
public EntityConfigurationOptions<TEntity> AddCustomMapper<TEntityMapper>(Action<IServiceCollection> configure, Func<IServiceProvider, TEntityMapper>? factory = null)
|
|
where TEntityMapper : class, IEntityMapper<TEntity>
|
|
{
|
|
configure(_services);
|
|
|
|
if (factory is null)
|
|
_services.AddSingleton<IEntityMapper<TEntity>, TEntityMapper>();
|
|
else
|
|
_services.AddSingleton(factory);
|
|
|
|
return this;
|
|
}
|
|
}
|