Defines base implementation for mediatr and fluentvalidation with samples

This commit is contained in:
BinaryAlley committed 2026-08-13 02:37:34 -07:00
1 parent 76db0c1597
commit 9a5c7473f9
33 files changed
+1123 -131

No files matched your search

@@ -0,0 +1,8 @@
namespace Lumina.Application.Common.CQRS;
/// <summary>
/// Marker interface for command types handled by <see cref="ICommandHandler{TCommand, TResult}"/>.
/// </summary>
public interface ICommand
{
}
@@ -0,0 +1,23 @@
#region ========================================================================= USING =====================================================================================
using System.Threading;
using System.Threading.Tasks;
#endregion
namespace Lumina.Application.Common.CQRS;
/// <summary>
/// Defines a contract for handling commands in the application layer.
/// Commands represent operations that modify application state.
/// </summary>
/// <typeparam name="TCommand">The type of command to handle.</typeparam>
/// <typeparam name="TResult">The type of result returned after handling the command.</typeparam>
public interface ICommandHandler<in TCommand, TResult> where TCommand : ICommand
{
/// <summary>
/// Handles the specified command and returns a result.
/// </summary>
/// <param name="command">The command to handle.</param>
/// <param name="cancellationToken">Token to monitor for cancellation requests.</param>
/// <returns>A task that represents the asynchronous operation, containing the result of the command execution.</returns>
Task<TResult> HandleAsync(TCommand command, CancellationToken cancellationToken = default);
}
@@ -0,0 +1,8 @@
namespace Lumina.Application.Common.CQRS;
/// <summary>
/// Marker interface for query types handled by <see cref="IQueryHandler{TQuery, TResult}"/>.
/// </summary>
public interface IQuery
{
}
@@ -0,0 +1,23 @@
#region ========================================================================= USING =====================================================================================
using System.Threading;
using System.Threading.Tasks;
#endregion
namespace Lumina.Application.Common.CQRS;
/// <summary>
/// Defines a contract for handling queries in the application layer.
/// Queries represent read-only operations that retrieve data without modifying application state.
/// </summary>
/// <typeparam name="TQuery">The type of query to handle.</typeparam>
/// <typeparam name="TResult">The type of result returned after handling the query.</typeparam>
public interface IQueryHandler<in TQuery, TResult> where TQuery : IQuery
{
/// <summary>
/// Handles the specified query and returns a result.
/// </summary>
/// <param name="query">The query to handle.</param>
/// <param name="cancellationToken">Token to monitor for cancellation requests.</param>
/// <returns>A task that represents the asynchronous operation, containing the result of the query execution.</returns>
Task<TResult> HandleAsync(TQuery query, CancellationToken cancellationToken = default);
}