using GFramework.Core.Abstractions.command; using GFramework.Core.rule; namespace GFramework.Core.command; /// /// 抽象命令类,实现 ICommand 接口,为具体命令提供基础架构支持 /// /// 命令输入参数类型,必须实现 ICommandInput 接口 /// 命令执行所需的输入参数 public abstract class AbstractCommand(TInput input) : ContextAwareBase, ICommand where TInput : ICommandInput { /// /// 执行命令的入口方法,实现 ICommand 接口的 Execute 方法 /// void ICommand.Execute() { OnExecute(input); } /// /// 命令执行的抽象方法,由派生类实现具体的命令逻辑 /// /// 命令执行所需的输入参数 protected abstract void OnExecute(TInput input); } /// /// 带返回值的抽象命令类,实现 ICommand{TResult} 接口,为需要返回结果的命令提供基础架构支持 /// /// 命令输入参数类型,必须实现 ICommandInput 接口 /// 命令执行后返回的结果类型 /// 命令执行所需的输入参数 public abstract class AbstractCommand(TInput input) : ContextAwareBase, ICommand where TInput : ICommandInput { /// /// 执行命令的入口方法,实现 ICommand{TResult} 接口的 Execute 方法 /// /// 命令执行后的结果 TResult ICommand.Execute() { return OnExecute(input); } /// /// 命令执行的抽象方法,由派生类实现具体的命令逻辑 /// /// 命令执行所需的输入参数 /// 命令执行后的结果 protected abstract TResult OnExecute(TInput input); }