From 35d05a46fa903b30c44c01e5380f194443087606 Mon Sep 17 00:00:00 2001 From: GeWuYou <95328647+GeWuYou@users.noreply.github.com> Date: Sat, 14 Feb 2026 19:09:38 +0800 Subject: [PATCH] =?UTF-8?q?refactor(architecture):=20=E6=9B=B4=E6=96=B0IAr?= =?UTF-8?q?chitectureContext=E6=8E=A5=E5=8F=A3=E4=B8=AD=E7=9A=84=E5=91=BD?= =?UTF-8?q?=E4=BB=A4=E5=92=8C=E6=9F=A5=E8=AF=A2=E6=96=B9=E6=B3=95=E7=AD=BE?= =?UTF-8?q?=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移除ICommand类型的using别名,直接使用完整命名空间 - 将SendCommand方法参数类型从ICommand改为command.ICommand - 添加Mediator模式的同步命令处理方法兼容性接口 - 添加Mediator模式的异步命令处理方法支持取消令牌 - 添加Mediator模式的同步查询处理方法兼容性接口 - 添加Mediator模式的异步查询处理方法支持取消令牌 - 移除重复的Mediator相关方法声明,优化接口结构 --- .../architecture/IArchitectureContext.cs | 78 ++++++++++--------- 1 file changed, 40 insertions(+), 38 deletions(-) diff --git a/GFramework.Core.Abstractions/architecture/IArchitectureContext.cs b/GFramework.Core.Abstractions/architecture/IArchitectureContext.cs index 5b0f1f7..286ee25 100644 --- a/GFramework.Core.Abstractions/architecture/IArchitectureContext.cs +++ b/GFramework.Core.Abstractions/architecture/IArchitectureContext.cs @@ -57,12 +57,33 @@ public interface IArchitectureContext /// 命令执行结果 TResult SendCommand(command.ICommand command); + /// + /// [Mediator] 发送命令的同步版本(不推荐,仅用于兼容性) + /// + /// 命令响应类型 + /// 要发送的命令对象 + /// 命令执行结果 + TResponse SendCommand(Mediator.ICommand command); + + /// /// 发送并异步执行一个命令 /// /// 要发送的命令 Task SendCommandAsync(IAsyncCommand command); + /// + /// [Mediator] 异步发送命令并返回结果 + /// 通过Mediator模式发送命令请求,支持取消操作 + /// + /// 命令响应类型 + /// 要发送的命令对象 + /// 取消令牌,用于取消操作 + /// 包含命令执行结果的ValueTask + ValueTask SendCommandAsync(Mediator.ICommand command, + CancellationToken cancellationToken = default); + + /// /// 发送并异步执行一个带返回值的命令 /// @@ -79,6 +100,14 @@ public interface IArchitectureContext /// 查询结果 TResult SendQuery(query.IQuery query); + /// + /// [Mediator] 发送查询的同步版本(不推荐,仅用于兼容性) + /// + /// 查询响应类型 + /// 要发送的查询对象 + /// 查询结果 + TResponse SendQuery(Mediator.IQuery command); + /// /// 异步发送一个查询请求 /// @@ -87,6 +116,17 @@ public interface IArchitectureContext /// 查询结果 Task SendQueryAsync(IAsyncQuery query); + /// + /// [Mediator] 异步发送查询并返回结果 + /// 通过Mediator模式发送查询请求,支持取消操作 + /// + /// 查询响应类型 + /// 要发送的查询对象 + /// 取消令牌,用于取消操作 + /// 包含查询结果的ValueTask + ValueTask SendQueryAsync(Mediator.IQuery command, + CancellationToken cancellationToken = default); + /// /// 发送一个事件 /// @@ -127,44 +167,6 @@ public interface IArchitectureContext /// TResponse SendRequest(IRequest request); - /// - /// [Mediator] 异步发送命令并返回结果 - /// 通过Mediator模式发送命令请求,支持取消操作 - /// - /// 命令响应类型 - /// 要发送的命令对象 - /// 取消令牌,用于取消操作 - /// 包含命令执行结果的ValueTask - ValueTask SendCommandAsync(Mediator.ICommand command, - CancellationToken cancellationToken = default); - - /// - /// [Mediator] 发送命令的同步版本(不推荐,仅用于兼容性) - /// - /// 命令响应类型 - /// 要发送的命令对象 - /// 命令执行结果 - TResponse SendCommand(Mediator.ICommand command); - - /// - /// [Mediator] 异步发送查询并返回结果 - /// 通过Mediator模式发送查询请求,支持取消操作 - /// - /// 查询响应类型 - /// 要发送的查询对象 - /// 取消令牌,用于取消操作 - /// 包含查询结果的ValueTask - ValueTask SendQueryAsync(Mediator.IQuery command, - CancellationToken cancellationToken = default); - - /// - /// [Mediator] 发送查询的同步版本(不推荐,仅用于兼容性) - /// - /// 查询响应类型 - /// 要发送的查询对象 - /// 查询结果 - TResponse SendQuery(Mediator.IQuery command); - /// /// 发布通知(一对多事件) ///