ResultEventArgs.cs 1.6 KB

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