mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-03-23 03:04:29 +08:00
- 在 ArchitectureContext 中新增 SendCommandAsync 方法支持异步命令执行 - 在 CommandBus 中实现 SendAsync 方法处理异步命令的发送和执行 - 在 ContextAwareExtensions 中扩展 SendCommandAsync 扩展方法 - 更新 IArchitectureContext 接口定义异步命令方法契约 - 更新 ICommandBus 接口定义异步命令执行方法 - 新增 AbstractAsyncCommand 抽象类提供异步命令基类实现 - 定义 IAsyncCommand 接口规范异步命令的行为 contract
26 lines
737 B
C#
26 lines
737 B
C#
using GFramework.Core.Abstractions.command;
|
|
using GFramework.Core.rule;
|
|
|
|
namespace GFramework.Core.command;
|
|
|
|
public abstract class AbstractAsyncCommand<TInput>(TInput input) : ContextAwareBase, IAsyncCommand
|
|
where TInput : ICommandInput
|
|
{
|
|
async Task IAsyncCommand.ExecuteAsync()
|
|
{
|
|
await OnExecuteAsync(input);
|
|
}
|
|
|
|
protected abstract Task OnExecuteAsync(TInput input);
|
|
}
|
|
|
|
public abstract class AbstractAsyncCommand<TInput, TResult>(TInput input) : ContextAwareBase, IAsyncCommand<TResult>
|
|
where TInput : ICommandInput
|
|
{
|
|
async Task<TResult> IAsyncCommand<TResult>.ExecuteAsync()
|
|
{
|
|
return await OnExecuteAsync(input);
|
|
}
|
|
|
|
protected abstract Task<TResult> OnExecuteAsync(TInput input);
|
|
} |