GFramework/GFramework.Core/Cqrs/LegacyCqrsDispatchHandlerBase.cs
gewuyou d7293aa475 refactor(core): 统一旧版命令查询到Cqrs运行时
- 重构 Core 兼容命令查询入口,使 legacy SendCommand/SendQuery 通过内部 bridge request 复用统一 CQRS runtime

- 新增 legacy bridge handler 与真实启动路径回归测试,验证默认架构初始化会自动接入统一 pipeline

- 更新 Core 与 CQRS 文档及 cqrs-rewrite 跟踪,记录 Mediator 尚未吸收的能力差距与后续收口方向
2026-05-07 17:20:14 +08:00

29 lines
985 B
C#

// Copyright (c) 2025-2026 GeWuYou
// SPDX-License-Identifier: Apache-2.0
using GFramework.Core.Abstractions.Rule;
using GFramework.Core.Rule;
namespace GFramework.Core.Cqrs;
/// <summary>
/// 为 legacy Core CQRS bridge handler 提供共享的上下文注入辅助逻辑。
/// </summary>
internal abstract class LegacyCqrsDispatchHandlerBase : ContextAwareBase
{
/// <summary>
/// 在执行 legacy 命令或查询前,把当前架构上下文显式注入给支持 <see cref="IContextAware" /> 的目标对象。
/// </summary>
protected void PrepareTarget(object target)
{
ArgumentNullException.ThrowIfNull(target);
if (target is IContextAware contextAware)
{
var context = Context ?? throw new InvalidOperationException(
"Legacy CQRS bridge handler requires an active architecture context before executing a context-aware target.");
contextAware.SetContext(context);
}
}
}