mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-05-09 01:54:30 +08:00
- 重构 Core 兼容命令查询入口,使 legacy SendCommand/SendQuery 通过内部 bridge request 复用统一 CQRS runtime - 新增 legacy bridge handler 与真实启动路径回归测试,验证默认架构初始化会自动接入统一 pipeline - 更新 Core 与 CQRS 文档及 cqrs-rewrite 跟踪,记录 Mediator 尚未吸收的能力差距与后续收口方向
42 lines
1.2 KiB
C#
42 lines
1.2 KiB
C#
// Copyright (c) 2025-2026 GeWuYou
|
||
// SPDX-License-Identifier: Apache-2.0
|
||
|
||
using System.Threading;
|
||
|
||
namespace GFramework.Core.Tests.Architectures;
|
||
|
||
/// <summary>
|
||
/// 为 legacy bridge pipeline 回归测试保存跨泛型闭包共享的计数状态。
|
||
/// </summary>
|
||
public static class LegacyBridgePipelineTracker
|
||
{
|
||
private static int _invocationCount;
|
||
|
||
/// <summary>
|
||
/// 获取当前进程内被识别为 legacy bridge request 的 pipeline 命中次数。
|
||
/// </summary>
|
||
public static int InvocationCount => Volatile.Read(ref _invocationCount);
|
||
|
||
/// <summary>
|
||
/// 重置计数器。
|
||
/// </summary>
|
||
public static void Reset()
|
||
{
|
||
Volatile.Write(ref _invocationCount, 0);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 若当前请求类型属于 Core legacy bridge request,则记录一次命中。
|
||
/// </summary>
|
||
public static void Record(Type requestType)
|
||
{
|
||
ArgumentNullException.ThrowIfNull(requestType);
|
||
|
||
if (string.Equals(requestType.Namespace, "GFramework.Core.Cqrs", StringComparison.Ordinal) &&
|
||
requestType.Name.Contains("Legacy", StringComparison.Ordinal))
|
||
{
|
||
Interlocked.Increment(ref _invocationCount);
|
||
}
|
||
}
|
||
}
|