mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-03-25 13:33:28 +08:00
refactor(core): 移除废弃的同步命令查询扩展方法并简化类型引用
- 移除了 ContextAwareCommandExtensions 中废弃的 SendCommand 同步方法 - 移除了 ContextAwareQueryExtensions 中废弃的 SendQuery 同步方法 - 简化了 ICommand 和 IQuery 的类型引用,移除冗长的命名空间前缀 - 保持了异步命令和查询方法的功能完整性
This commit is contained in:
parent
71b5831261
commit
b4d17edeee
@ -8,24 +8,6 @@ namespace GFramework.Core.extensions;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static class ContextAwareCommandExtensions
|
public static class ContextAwareCommandExtensions
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// [Mediator] 发送命令的同步版本(不推荐,仅用于兼容性)
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="TResponse">命令响应类型</typeparam>
|
|
||||||
/// <param name="contextAware">实现 IContextAware 接口的对象</param>
|
|
||||||
/// <param name="command">要发送的命令对象</param>
|
|
||||||
/// <returns>命令执行结果</returns>
|
|
||||||
/// <exception cref="ArgumentNullException">当 contextAware 或 command 为 null 时抛出</exception>
|
|
||||||
public static TResponse SendCommand<TResponse>(this IContextAware contextAware,
|
|
||||||
Mediator.ICommand<TResponse> command)
|
|
||||||
{
|
|
||||||
ArgumentNullException.ThrowIfNull(contextAware);
|
|
||||||
ArgumentNullException.ThrowIfNull(command);
|
|
||||||
|
|
||||||
var context = contextAware.GetContext();
|
|
||||||
return context.SendCommand(command);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 发送一个带返回结果的命令
|
/// 发送一个带返回结果的命令
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -35,7 +17,7 @@ public static class ContextAwareCommandExtensions
|
|||||||
/// <returns>命令执行结果</returns>
|
/// <returns>命令执行结果</returns>
|
||||||
/// <exception cref="ArgumentNullException">当 contextAware 或 command 为 null 时抛出</exception>
|
/// <exception cref="ArgumentNullException">当 contextAware 或 command 为 null 时抛出</exception>
|
||||||
public static TResult SendCommand<TResult>(this IContextAware contextAware,
|
public static TResult SendCommand<TResult>(this IContextAware contextAware,
|
||||||
Abstractions.command.ICommand<TResult> command)
|
ICommand<TResult> command)
|
||||||
{
|
{
|
||||||
ArgumentNullException.ThrowIfNull(contextAware);
|
ArgumentNullException.ThrowIfNull(contextAware);
|
||||||
ArgumentNullException.ThrowIfNull(command);
|
ArgumentNullException.ThrowIfNull(command);
|
||||||
@ -50,7 +32,7 @@ public static class ContextAwareCommandExtensions
|
|||||||
/// <param name="contextAware">实现 IContextAware 接口的对象</param>
|
/// <param name="contextAware">实现 IContextAware 接口的对象</param>
|
||||||
/// <param name="command">要发送的命令</param>
|
/// <param name="command">要发送的命令</param>
|
||||||
/// <exception cref="ArgumentNullException">当 contextAware 或 command 为 null 时抛出</exception>
|
/// <exception cref="ArgumentNullException">当 contextAware 或 command 为 null 时抛出</exception>
|
||||||
public static void SendCommand(this IContextAware contextAware, Abstractions.command.ICommand command)
|
public static void SendCommand(this IContextAware contextAware, ICommand command)
|
||||||
{
|
{
|
||||||
ArgumentNullException.ThrowIfNull(contextAware);
|
ArgumentNullException.ThrowIfNull(contextAware);
|
||||||
ArgumentNullException.ThrowIfNull(command);
|
ArgumentNullException.ThrowIfNull(command);
|
||||||
|
|||||||
@ -8,23 +8,6 @@ namespace GFramework.Core.extensions;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static class ContextAwareQueryExtensions
|
public static class ContextAwareQueryExtensions
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// [Mediator] 发送查询的同步版本(不推荐,仅用于兼容性)
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="TResponse">查询响应类型</typeparam>
|
|
||||||
/// <param name="contextAware">实现 IContextAware 接口的对象</param>
|
|
||||||
/// <param name="query">要发送的查询对象</param>
|
|
||||||
/// <returns>查询结果</returns>
|
|
||||||
/// <exception cref="ArgumentNullException">当 contextAware 或 query 为 null 时抛出</exception>
|
|
||||||
public static TResponse SendQuery<TResponse>(this IContextAware contextAware, Mediator.IQuery<TResponse> query)
|
|
||||||
{
|
|
||||||
ArgumentNullException.ThrowIfNull(contextAware);
|
|
||||||
ArgumentNullException.ThrowIfNull(query);
|
|
||||||
|
|
||||||
var context = contextAware.GetContext();
|
|
||||||
return context.SendQuery(query);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 发送一个查询请求
|
/// 发送一个查询请求
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -33,7 +16,7 @@ public static class ContextAwareQueryExtensions
|
|||||||
/// <param name="query">要发送的查询</param>
|
/// <param name="query">要发送的查询</param>
|
||||||
/// <returns>查询结果</returns>
|
/// <returns>查询结果</returns>
|
||||||
/// <exception cref="ArgumentNullException">当 contextAware 或 query 为 null 时抛出</exception>
|
/// <exception cref="ArgumentNullException">当 contextAware 或 query 为 null 时抛出</exception>
|
||||||
public static TResult SendQuery<TResult>(this IContextAware contextAware, Abstractions.query.IQuery<TResult> query)
|
public static TResult SendQuery<TResult>(this IContextAware contextAware, IQuery<TResult> query)
|
||||||
{
|
{
|
||||||
ArgumentNullException.ThrowIfNull(contextAware);
|
ArgumentNullException.ThrowIfNull(contextAware);
|
||||||
ArgumentNullException.ThrowIfNull(query);
|
ArgumentNullException.ThrowIfNull(query);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user