using System.Reflection; using GB5Shared.DaprCache; using GB5Shared.DALCache; using GB5Shared.EntityHandler; using GB5Shared.EventLogPublish; using GB5Shared.GenerateAutoNumber; using GB5Shared.GB5Library.Qualifier; using GB5Shared.GOP.Qualifier; using GB5Shared.Hosting; using GB5Shared.PickListGenerator; using GB5Shared.PubSub.OutBox; using GB5Shared.Validation; using GB5Shared.Vault; using GB5Shared.WorkFlow.WorkFlowEngine; using GB5Shared.WorkFlow.WorkFlowRunTime; namespace CMSSL; public class CMSModule : IModule { public void Register(IServiceCollection services, IConfiguration configuration) { services.AddScoped(); services.AddScoped(); services.AddScoped(); services.AddScoped(); services.AddScoped(); services.AddScoped(); services.AddScoped(); // Site/Page platform — registered here (not just CMSSL/Program.cs's standalone run) // because a host that embeds CMS via this Register() method (e.g. EngagementHost) never // executes CMSSL/Program.cs at all. Found by diffing a fresh EngagementHost publish // against 217.216.78.142's live config before deploying: none of these had any other // registration source in that specific host's module set. Registered here directly // (rather than relying on some other co-hosted module happening to register the same // thing, e.g. PERM/OKR/FBCK for BaseEntityAppService<>/IQualifierFacade/IOutBox or DMS // for IVaultService) so CMS keeps working regardless of which sibling modules a future // host does or doesn't include — a harmless duplicate registration if a sibling already // provides one, per the same pattern DXP/PERM/OKR/FBCK/MM/etc. each already follow // (every module registers its own full dependency set, none rely on a sibling's). // AddGB5Vault throws if "Vault:Address" isn't configured for this host — in that case // ModuleLoader's isolation excludes CMS entirely from that host, a clean degradation // rather than a crash, exactly as intended for a genuinely unconfigured environment. services.AddScoped(typeof(BaseEntityAppService<>), typeof(BaseEntityAppService<>)); services.AddScoped(); services.AddGB5QualifierEngine(); services.AddScoped(); services.AddScoped(); services.AddScoped(); services.AddHttpClient("CmsDataSourceClient", c => c.Timeout = TimeSpan.FromSeconds(15)); services.AddGB5Vault(configuration); var cmsBLLAssembly = Assembly.Load("CMSBLL"); var cmsDALAssembly = Assembly.Load("CMSDAL"); services.Scan(scan => scan .FromAssemblies(cmsBLLAssembly, cmsDALAssembly) .AddClasses(c => c.Where(t => !t.IsAbstract && !t.IsInterface && (t.Namespace == null || !t.Namespace.Contains(".DTO")))) .AsImplementedInterfaces() .WithScopedLifetime()); } public void MapEndpoints(WebApplication app) { } }