ResultEventArgs.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. namespace Terminal.Gui.App;
  2. using System;
  3. #pragma warning disable CS1711
  4. /// <summary>
  5. /// Provides data for events that produce a result in a cancellable workflow in the Cancellable Work Pattern (CWP).
  6. /// </summary>
  7. /// <remarks>
  8. /// Used for workflows where a result (e.g., <see cref="Command"/> outcome, <see cref="Attribute"/> resolution) is
  9. /// being produced or cancelled, such as for methods like <see cref="View.GetAttributeForRole"/>.
  10. /// </remarks>
  11. /// <typeparam name="T">The type of the result.</typeparam>
  12. /// <seealso cref="CancelEventArgs{T}"/>
  13. /// <seealso cref="ValueChangingEventArgs{T}"/>
  14. public class ResultEventArgs<T>
  15. {
  16. /// <summary>
  17. /// Gets or sets the result of the operation, which may be null if no result is provided.
  18. /// </summary>
  19. public T? Result { get; set; }
  20. /// <summary>
  21. /// Gets or sets a value indicating whether the operation has been handled.
  22. /// If true, the operation is considered handled and may use the provided result.
  23. /// </summary>
  24. public bool Handled { get; set; }
  25. /// <summary>
  26. /// Initializes a new instance of the <see cref="ResultEventArgs{T}"/> class with no initial result.
  27. /// </summary>
  28. public ResultEventArgs () { }
  29. /// <summary>
  30. /// Initializes a new instance of the <see cref="ResultEventArgs{T}"/> class with an initial result.
  31. /// </summary>
  32. /// <param name="result">The initial result, which may be null for optional outcomes.</param>
  33. public ResultEventArgs (T? result)
  34. {
  35. Result = result;
  36. }
  37. }
  38. #pragma warning restore CS1711