using System.ComponentModel; using GFramework.Core.Abstractions.Rule; using GFramework.Cqrs.Abstractions.Cqrs.Command; using GFramework.Cqrs.Extensions; namespace GFramework.Core.Extensions; /// /// 提供对 接口的 CQRS 命令扩展方法。 /// 该类型保留旧名称以兼容历史调用点;新代码应改用 。 /// 兼容层计划在未来的 major 版本中移除,因此不会继续承载新能力。 /// [EditorBrowsable(EditorBrowsableState.Never)] [Obsolete( "Use GFramework.Core.Extensions.ContextAwareCqrsCommandExtensions instead. This compatibility alias will be removed in a future major version.")] public static class ContextAwareMediatorCommandExtensions { /// /// 发送命令的同步版本(不推荐,仅用于兼容性) /// /// 命令响应类型 /// 实现 IContextAware 接口的对象 /// 要发送的命令对象 /// 命令执行结果 /// 当 contextAware 或 command 为 null 时抛出 public static TResponse SendCommand(this IContextAware contextAware, ICommand command) { return ContextAwareCqrsCommandExtensions.SendCommand(contextAware, command); } /// /// 异步发送命令并返回结果 /// /// 命令响应类型 /// 实现 IContextAware 接口的对象 /// 要发送的命令对象 /// 取消令牌,用于取消操作 /// 包含命令执行结果的ValueTask /// 当 contextAware 或 command 为 null 时抛出 public static ValueTask SendCommandAsync(this IContextAware contextAware, ICommand command, CancellationToken cancellationToken = default) { return ContextAwareCqrsCommandExtensions.SendCommandAsync( contextAware, command, cancellationToken); } }