mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 18:21:10 +00:00
Defines base implementation for mediatr and fluentvalidation with samples
This commit is contained in:
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);
|
||||
}
|
||||
Reference in new issue
Block a user