using System; using GFramework.Core.Abstractions.Logging; using GFramework.Core.Ioc; using GFramework.Core.Logging; using GFramework.Cqrs.Abstractions.Cqrs; namespace GFramework.Cqrs.Tests.Cqrs; /// /// 模拟源码生成器为某个程序集生成的 CQRS 处理器注册器。 /// internal sealed class GeneratedNotificationHandlerRegistry : ICqrsHandlerRegistry { /// /// 将测试通知处理器注册到目标服务集合。 /// /// 承载处理器映射的服务集合。 /// 用于记录注册诊断的日志器。 public void Register(IServiceCollection services, ILogger logger) { ArgumentNullException.ThrowIfNull(services); ArgumentNullException.ThrowIfNull(logger); services.AddTransient( typeof(INotificationHandler), typeof(GeneratedRegistryNotificationHandler)); logger.Debug( $"Registered CQRS handler {typeof(GeneratedRegistryNotificationHandler).FullName} as {typeof(INotificationHandler).FullName}."); } }