GFramework/GFramework.Core.Tests/Architectures/LegacyBridgePipelineTracker.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

42 lines
1.2 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 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);
}
}
}