Files
prefab-page-detail/Prefab/Handler/IHandler.cs
2025-10-27 17:39:18 -04:00

25 lines
1.3 KiB
C#

namespace Prefab.Handler;
/// <summary>
/// Defines a handler that processes a request and returns a response asynchronously.
/// </summary>
/// <remarks>Implementations of this interface encapsulate the logic required to handle a specific request and
/// produce a result. Handlers are typically used in command or query processing pipelines to separate request handling
/// logic from other application concerns.</remarks>
/// <typeparam name="TResponse">The type of the response returned by the handler.</typeparam>
public interface IHandler<TResponse>
{
Task<TResponse> Execute(CancellationToken cancellationToken);
}
/// <summary>
/// Defines a contract for handling a request and producing a response asynchronously.
/// </summary>
/// <remarks>Implementations of this interface should be thread-safe if they are intended to be used concurrently.
/// The interface is typically used in request/response or command/query processing pipelines.</remarks>
/// <typeparam name="TRequest">The type of the request to be handled.</typeparam>
/// <typeparam name="TResponse">The type of the response returned after handling the request.</typeparam>
public interface IHandler<in TRequest, TResponse>
{
Task<TResponse> Execute(TRequest request, CancellationToken cancellationToken);
}