GFramework/GFramework.Core/query/AbstractAsyncQuery.cs
GeWuYou 42ddb80248 feat(core): 添加异步查询系统并优化命令系统实现
- 新增 AbstractAsyncQuery 基类支持异步查询操作
- 实现 AsyncQueryBus 和 IAsyncQueryBus 查询总线功能
- 添加 IAsyncQuery 接口定义异步查询契约
- 重构 CommandBus 的 SendAsync 方法移除不必要的 await
- 为 AbstractAsyncCommand 添加完整 XML 文档注释
- 更新 TEST_COVERAGE_PLAN.md 反映测试覆盖率提升至 91.5%
2026-01-18 20:39:23 +08:00

32 lines
1.1 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.

using GFramework.Core.Abstractions.query;
using GFramework.Core.rule;
namespace GFramework.Core.query;
/// <summary>
/// 抽象异步查询基类用于处理输入类型为TInput、结果类型为TResult的异步查询操作
/// </summary>
/// <typeparam name="TInput">查询输入类型必须实现IQueryInput接口</typeparam>
/// <typeparam name="TResult">查询结果类型</typeparam>
/// <param name="input">查询输入参数</param>
public abstract class AbstractAsyncQuery<TInput, TResult>(
TInput input
) : ContextAwareBase, IAsyncQuery<TResult>
where TInput : IQueryInput
{
/// <summary>
/// 执行异步查询操作
/// </summary>
/// <returns>返回查询结果的异步任务</returns>
public Task<TResult> DoAsync()
{
return OnDoAsync(input);
}
/// <summary>
/// 抽象方法,用于实现具体的异步查询逻辑
/// </summary>
/// <param name="input">查询输入参数</param>
/// <returns>返回查询结果的异步任务</returns>
protected abstract Task<TResult> OnDoAsync(TInput input);
}