using GB5Shared.EntityHandler;
using GB5Shared.GOP.Qualifier.Executors;
using GB5Shared.GOP.GBQueryExecutor;
using Microsoft.Extensions.DependencyInjection;
namespace GB5Shared.GOP.Qualifier
{
///
/// Registers the relocated GOP qualifier engine (versioned/DAG-scheduled, admin-authored)
/// and its GBQueryExecutor dependency. GB5Shared is not covered by any host's assembly
/// scan (every FromAssemblies() scan lists only that host's own BLL/DAL assemblies), so
/// every module that resolves IQualifierFacade — directly or via BaseEntityAppService —
/// needs this call once at startup.
/// Call once per host: builder.Services.AddGB5QualifierEngine();
///
public static class QualifierEngineServiceExtensions
{
public static IServiceCollection AddGB5QualifierEngine(this IServiceCollection services)
{
services.AddMemoryCache();
services.AddScoped();
services.AddScoped();
services.AddScoped();
// Open-generic registration — QualifierBLL constructor-injects
// BaseEntityAppService and BaseEntityAppService
// directly (no interface), so it isn't picked up by any host's AsImplementedInterfaces()
// scan even when GB5Shared is included in that scan.
services.AddScoped(typeof(BaseEntityAppService<>));
services.AddScoped();
services.AddScoped();
services.AddScoped();
services.AddScoped();
services.AddScoped();
services.AddScoped();
services.AddKeyedScoped("NCalc");
services.AddKeyedScoped("DataSource");
services.AddKeyedScoped("Service");
// Singleton — holds a ConcurrentDictionary of registered cache keys per tenant
// across ALL requests; must be the same instance on every resolution.
services.AddSingleton();
services.AddSingleton(sp =>
sp.GetRequiredService());
return services;
}
}
}