GFramework/GFramework.Core/command/AbstractCommandWithInput.cs
GeWuYou 21c5d1bc68 refactor(command): 重构命令和查询抽象基类以支持输入参数分离
- 将 AbstractAsyncCommand 拆分为 AbstractAsyncCommand 和 AbstractAsyncCommandWithInput
- 将 AbstractAsyncCommand<TInput, TResult> 移至新的 AbstractAsyncCommandWithResult 类
- 将 AbstractCommand 拆分为 AbstractCommand 和 AbstractCommandWithInput
- 将 AbstractCommand<TInput, TResult> 移至新的 AbstractCommandWithResult 类
- 将 AbstractAsyncQuery 简化为不带输入参数的版本
- 将 AbstractQuery 简化为不带输入参数的版本
- 创建新的 AbstractAsyncQueryWithResult 类处理带输入参数的异步查询
- 创建新的 AbstractQueryWithResult 类处理带输入参数的同步查询
2026-01-26 13:03:50 +08:00

27 lines
954 B
C#

using GFramework.Core.Abstractions.command;
using GFramework.Core.rule;
namespace GFramework.Core.command;
/// <summary>
/// 抽象命令类,实现 ICommand 接口,为具体命令提供基础架构支持
/// </summary>
/// <typeparam name="TInput">命令输入参数类型,必须实现 ICommandInput 接口</typeparam>
/// <param name="input">命令执行所需的输入参数</param>
public abstract class AbstractCommand<TInput>(TInput input) : ContextAwareBase, ICommand
where TInput : ICommandInput
{
/// <summary>
/// 执行命令的入口方法,实现 ICommand 接口的 Execute 方法
/// </summary>
void ICommand.Execute()
{
OnExecute(input);
}
/// <summary>
/// 命令执行的抽象方法,由派生类实现具体的命令逻辑
/// </summary>
/// <param name="input">命令执行所需的输入参数</param>
protected abstract void OnExecute(TInput input);
}