Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 2 additions & 20 deletions GFramework.Core/extensions/ContextAwareCommandExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,6 @@ namespace GFramework.Core.extensions;
/// </summary>
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>
Expand All @@ -35,7 +17,7 @@ public static TResponse SendCommand<TResponse>(this IContextAware contextAware,
/// <returns>命令执行结果</returns>
/// <exception cref="ArgumentNullException">当 contextAware 或 command 为 null 时抛出</exception>
public static TResult SendCommand<TResult>(this IContextAware contextAware,
Abstractions.command.ICommand<TResult> command)
ICommand<TResult> command)
{
ArgumentNullException.ThrowIfNull(contextAware);
ArgumentNullException.ThrowIfNull(command);
Expand All @@ -50,7 +32,7 @@ public static TResult SendCommand<TResult>(this IContextAware contextAware,
/// <param name="contextAware">实现 IContextAware 接口的对象</param>
/// <param name="command">要发送的命令</param>
/// <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(command);
Expand Down
19 changes: 1 addition & 18 deletions GFramework.Core/extensions/ContextAwareQueryExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,6 @@ namespace GFramework.Core.extensions;
/// </summary>
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>
Expand All @@ -33,7 +16,7 @@ public static TResponse SendQuery<TResponse>(this IContextAware contextAware, Me
/// <param name="query">要发送的查询</param>
/// <returns>查询结果</returns>
/// <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(query);
Expand Down
Loading