2
0

CommandContext.cs 1000 B

123456789101112131415161718192021222324252627282930
  1. #nullable enable
  2. namespace Terminal.Gui;
  3. #pragma warning disable CS1574 // XML comment has cref attribute that could not be resolved
  4. /// <summary>
  5. /// Provides context for a <see cref="Command"/> invocation.
  6. /// </summary>
  7. /// <seealso cref="View.InvokeCommand"/>.
  8. #pragma warning restore CS1574 // XML comment has cref attribute that could not be resolved
  9. public record struct CommandContext<TBinding> : ICommandContext
  10. {
  11. /// <summary>
  12. /// Initializes a new instance with the specified <see cref="Command"/>,
  13. /// </summary>
  14. /// <param name="command"></param>
  15. /// <param name="binding"></param>
  16. public CommandContext (Command command, TBinding? binding)
  17. {
  18. Command = command;
  19. Binding = binding;
  20. }
  21. /// <inheritdoc />
  22. public Command Command { get; set; }
  23. /// <summary>
  24. /// The keyboard or mouse minding that was used to invoke the <see cref="Command"/>, if any.
  25. /// </summary>
  26. public TBinding? Binding { get; set; }
  27. }