CommandContext.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. 
  2. namespace Terminal.Gui.Input;
  3. #pragma warning disable CS1574, CS0419 // 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, CS0419 // 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="source"></param>
  16. /// <param name="binding"></param>
  17. public CommandContext (Command command, View? source, TBinding? binding)
  18. {
  19. Command = command;
  20. Binding = binding;
  21. Source = source;
  22. }
  23. /// <inheritdoc />
  24. public Command Command { get; set; }
  25. /// <inheritdoc />
  26. public View? Source { get; set; }
  27. /// <summary>
  28. /// The keyboard or mouse minding that was used to invoke the <see cref="Command"/>, if any.
  29. /// </summary>
  30. public TBinding? Binding { get; set; }
  31. }