Files
CommandHook/CommandHook/CommandRegistration.cs
T

30 lines
984 B
C#

namespace CommandHook;
/// <summary>
/// The pair of callbacks a listener provides for a command. Either one can be null.
/// </summary>
public struct CommandRegistration
{
/// <summary>
/// Called before the command runs. Return a non-null <see cref="TextCommandResult"/>
/// to cancel the command, report that result to the caller, and skip any
/// remaining Before listeners. Return null to let the command run.
/// </summary>
public readonly CommandBeforeDelegate? Before;
/// <summary>
/// Called after the command runs, with its result. Not called if a Before
/// listener cancelled the command.
/// </summary>
public readonly CommandAfterDelegate? After;
/// <summary>
/// Creates a registration. Pass null for either delegate to only hook one side.
/// </summary>
public CommandRegistration(CommandBeforeDelegate? before, CommandAfterDelegate? after)
{
Before = before;
After = after;
}
}