refactor(EntityConfigurationOptions): aktualisiert, um IServiceCollection mit Callback zu konfigurieren
This commit is contained in:
@@ -12,9 +12,16 @@ public class EntityConfigurationOptions<TEntity>
|
||||
_services = services;
|
||||
}
|
||||
|
||||
public EntityConfigurationOptions<TEntity> AddCustomMapper(Func<IServiceProvider, IEntityMapper<TEntity>> factory)
|
||||
public EntityConfigurationOptions<TEntity> AddCustomMapper<TEntityMapper>(Action<IServiceCollection> configure, Func<IServiceProvider, TEntityMapper>? factory = null)
|
||||
where TEntityMapper : class, IEntityMapper<TEntity>
|
||||
{
|
||||
_services.AddSingleton(factory);
|
||||
configure(_services);
|
||||
|
||||
if (factory is null)
|
||||
_services.AddSingleton<IEntityMapper<TEntity>, TEntityMapper>();
|
||||
else
|
||||
_services.AddSingleton(factory);
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user