using System.Reflection; using GB5Shared.GOP.Qualifier; using GB5Shared.Authorization; using GB5Shared.DaprCache; using GB5Shared.DTO.Framework.Login; using GB5Shared.EntityHandler; using GB5Shared.GB5Library.Qualifier; using GB5Shared.Hosting; using GB5Shared.ListQuery; using GB5Shared.PubSub.OutBox; using Microsoft.Extensions.Hosting; using GB5Shared.WorkFlow.WorkFlowEngine; using GB5Shared.WorkFlow.WorkFlowRunTime; using Newtonsoft.Json; namespace SwSL; public class SwModule : IModule { public string DisplayName => "SqlWorkbench"; public void Register(IServiceCollection services, IConfiguration configuration) { services.AddHttpContextAccessor(); services.AddScoped(sp => { var ctx = sp.GetRequiredService().HttpContext; if (ctx != null && ctx.Request.Headers.TryGetValue("Login", out var h)) return JsonConvert.DeserializeObject(h!)!; return new LoginDTO(); }); services.AddScoped(typeof(BaseEntityAppService<>)); services.AddScoped(); services.AddGB5QualifierEngine(); services.AddScoped(); services.AddScoped(); services.AddScoped(); services.AddScoped(); services.AddScoped(); services.AddMenuRightsAuthorization(); // Same block as Program.cs (standalone path) — host-aggregated mode gets an identical DI // graph for ClientDatabaseProvisioner's config + Vault client. services.Configure( configuration.GetSection(SwBLL.Provisioning.SqlServerProvisioningOptions.SectionName)); services.AddSingleton(sp => { var authMethod = new VaultSharp.V1.AuthMethods.Token.TokenAuthMethodInfo(configuration["Vault:Token"]!); var settings = new VaultSharp.VaultClientSettings(configuration["Vault:Address"]!, authMethod); return new VaultSharp.VaultClient(settings); }); var bll = Assembly.Load("SwBLL"); var dal = Assembly.Load("SwDAL"); services.Scan(scan => scan .FromAssemblies(bll, dal) .AddClasses(c => c.Where(t => !t.IsAbstract && !t.IsInterface && !t.Name.EndsWith("ListQuery") && !t.Name.EndsWith("Criteria") && !t.Name.EndsWith("ListDTO") && !t.Name.EndsWith("DTO"))) .AsImplementedInterfaces() .WithScopedLifetime()); services.AddListInfrastructure(dal); // ServerConfigBLL/ServerConfigDAL (ClientDatabaseProvisioner's MSERVER/MSERVERCONFIG // registration dependency) now live in SwBLL/SwDAL themselves, so the main scan above // already registers them — no separate Framework scan needed. } public void MapEndpoints(WebApplication app) { } }