~ruther/NosSmooth

ref: 6528818bbd996abf31849e916aba6c391c155be5 NosSmooth/Core/NosSmooth.Core/Commands/ICommandHandler.cs -rw-r--r-- 1.2 KiB
6528818b — Rutherther chore(core): update version 3 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
//
//  ICommandHandler.cs
//
//  Copyright (c) František Boháček. All rights reserved.
//  Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System.Threading;
using System.Threading.Tasks;
using Remora.Results;

namespace NosSmooth.Core.Commands;

/// <summary>
/// Represents interface for command handlers that process <see cref="ICommand"/>.
/// </summary>
public interface ICommandHandler
{
}

/// <summary>
/// Represents interface of class that handles <see cref="ICommand"/> of type <typeparamref name="TCommand"/>.
/// </summary>
/// <typeparam name="TCommand">The command type that this handler can execute.</typeparam>
public interface ICommandHandler<TCommand> : ICommandHandler
    where TCommand : ICommand
{
    /// <summary>
    /// Execute the given command.
    /// </summary>
    /// <param name="command">The command to execute.</param>
    /// <param name="ct">The cancellation token for cancelling the operation.</param>
    /// <returns>A result that may or may not have succeeded.</returns>
    public Task<Result> HandleCommand(TCommand command, CancellationToken ct = default);
}
Do not follow this link