using GFramework.Core.Abstractions.Cqrs.Command;
using GFramework.Core.Abstractions.Rule;
using GFramework.Core.Cqrs.Extensions;
namespace GFramework.Core.Extensions;
///
/// 提供对 接口的 CQRS 命令扩展方法。
/// 该类型保留旧名称以兼容历史调用点;新代码应改用 。
///
[Obsolete("Use GFramework.Core.Cqrs.Extensions.ContextAwareCqrsCommandExtensions instead.")]
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);
}
}