Projektstruktur optimiert und Benutzer- & Gruppenverzeichnisdienste abgeschlossen.

This commit is contained in:
Developer 02
2024-03-08 15:00:37 +01:00
parent 846364351e
commit 085a1ffdec
363 changed files with 7785 additions and 8132 deletions

View File

@@ -0,0 +1,27 @@
using DigitalData.Core.Contracts.Infrastructure;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using System.DirectoryServices;
namespace DigitalData.Core.Infrastructure
{
public static class DIExtensions
{
/// <summary>
/// Adds a CRUD repository for a specific entity type to the service collection.
/// </summary>
/// <typeparam name="TEntity">The entity type for which the repository is registered.</typeparam>
/// <typeparam name="TId">The type of the entity's identifier.</typeparam>
/// <typeparam name="TDbContext">The DbContext type used by the repository.</typeparam>
/// <param name="services">The <see cref="IServiceCollection"/> to add the repository to.</param>
/// <param name="configureRepository">An optional action to configure additional services for the repository.</param>
/// <returns>The original <see cref="IServiceCollection"/> instance, allowing further configuration.</returns>
public static IServiceCollection AddCleanCRUDRepository<TEntity, TId, TDbContext, TCRUDRepository>(this IServiceCollection services, Action<IServiceCollection>? configureRepository = null)
where TCRUDRepository : CRUDRepository<TEntity, TId, TDbContext> where TEntity : class where TDbContext : DbContext
{
services.AddScoped<ICRUDRepository<TEntity, TId>, TCRUDRepository>();
configureRepository?.Invoke(services);
return services;
}
}
}