mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-05-07 00:39:00 +08:00
- 新增ContextAwareMediatorCommandExtensions提供命令扩展方法兼容性支持 - 新增ContextAwareMediatorQueryExtensions提供查询扩展方法兼容性支持 - 添加LoggerFactoryResolver实现全局日志工厂访问入口 - 实现TypeForwarders将核心类型转发到正确程序集 - 添加MediatorCompatibilityDeprecationTests验证弃用策略 - 扩展LoggerFactoryTests覆盖并发初始化和回退逻辑 - 迁移CommandBase到Core.Cqrs.Command命名空间 - 移动LoggingBehavior到GFramework.Cqrs.Cqrs.Behaviors - 添加AbstractStreamQueryHandler支持流式查询处理 - 创建NotificationBase提供通知基类实现
52 lines
2.0 KiB
C#
52 lines
2.0 KiB
C#
using GFramework.Core.Abstractions.Cqrs;
|
||
using GFramework.Core.Abstractions.Ioc;
|
||
using GFramework.Core.Abstractions.Logging;
|
||
using GFramework.Cqrs.Abstractions.Cqrs;
|
||
using GFramework.Cqrs.Internal;
|
||
|
||
namespace GFramework.Cqrs;
|
||
|
||
/// <summary>
|
||
/// 提供 CQRS runtime 默认实现的跨程序集创建入口。
|
||
/// </summary>
|
||
/// <remarks>
|
||
/// <see cref="GFramework.Core" /> 需要在不暴露内部实现细节的前提下接入默认 CQRS runtime,
|
||
/// 因此通过该工厂返回抽象接口,而不是直接公开内部 dispatcher / registrar 类型。
|
||
/// </remarks>
|
||
public static class CqrsRuntimeFactory
|
||
{
|
||
/// <summary>
|
||
/// 创建默认 CQRS runtime 分发器。
|
||
/// </summary>
|
||
/// <param name="container">目标依赖注入容器。</param>
|
||
/// <param name="logger">用于 runtime 诊断的日志器。</param>
|
||
/// <returns>默认 CQRS runtime。</returns>
|
||
/// <exception cref="ArgumentNullException">
|
||
/// <paramref name="container" /> 或 <paramref name="logger" /> 为 <see langword="null" />。
|
||
/// </exception>
|
||
public static ICqrsRuntime CreateRuntime(IIocContainer container, ILogger logger)
|
||
{
|
||
ArgumentNullException.ThrowIfNull(container);
|
||
ArgumentNullException.ThrowIfNull(logger);
|
||
|
||
return new CqrsDispatcher(container, logger);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 创建默认 CQRS 处理器注册器。
|
||
/// </summary>
|
||
/// <param name="container">目标依赖注入容器。</param>
|
||
/// <param name="logger">用于注册阶段诊断的日志器。</param>
|
||
/// <returns>默认 CQRS handler registrar。</returns>
|
||
/// <exception cref="ArgumentNullException">
|
||
/// <paramref name="container" /> 或 <paramref name="logger" /> 为 <see langword="null" />。
|
||
/// </exception>
|
||
public static ICqrsHandlerRegistrar CreateHandlerRegistrar(IIocContainer container, ILogger logger)
|
||
{
|
||
ArgumentNullException.ThrowIfNull(container);
|
||
ArgumentNullException.ThrowIfNull(logger);
|
||
|
||
return new DefaultCqrsHandlerRegistrar(container, logger);
|
||
}
|
||
}
|