using System.Reflection; using GB5Shared.DTO.Framework.Login; using GB5Shared.Hosting; using GB5Shared.ListQuery; using Newtonsoft.Json; namespace TCMSSL; public class TCMSModule : IModule { 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(); }); var bll = Assembly.Load("TCMSBLL"); var dal = Assembly.Load("TCMSDAL"); services.Scan(scan => scan .FromAssemblies(bll, dal) .AddClasses(c => c.Where(t => !t.IsAbstract && !t.IsInterface && (t.Namespace == null || !t.Namespace.Contains(".DTO")))) .AsImplementedInterfaces() .WithScopedLifetime()); services.AddListInfrastructure(dal); } public void MapEndpoints(WebApplication app) { } }