ValueChangedEventArgs.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #nullable enable
  2. namespace Terminal.Gui.App;
  3. /// <summary>
  4. /// Provides data for events that notify of a completed property change in the Cancellable Work Pattern (CWP).
  5. /// </summary>
  6. /// <remarks>
  7. /// <para>
  8. /// Used in post-change events raised by <see cref="CWPPropertyHelper.ChangeProperty{T}"/> to notify
  9. /// subscribers of a property change, such as in <see cref="OrientationHelper"/> when the
  10. /// <see cref="Orientation"/> property is updated or <see cref="View.SchemeName"/> when the scheme name changes.
  11. /// </para>
  12. /// </remarks>
  13. /// <typeparam name="T">The type of the property value, which may be a nullable reference type (e.g., <see cref="string"/>?).</typeparam>
  14. /// <seealso cref="ValueChangingEventArgs{T}"/>
  15. /// <seealso cref="CWPPropertyHelper"/>
  16. public class ValueChangedEventArgs<T>
  17. {
  18. /// <summary>
  19. /// Gets the value before the change, which may be null for nullable types.
  20. /// </summary>
  21. public T OldValue { get; }
  22. /// <summary>
  23. /// Gets the value after the change, which may be null for nullable types.
  24. /// </summary>
  25. public T NewValue { get; }
  26. /// <summary>
  27. /// Initializes a new instance of the <see cref="ValueChangedEventArgs{T}"/> class.
  28. /// </summary>
  29. /// <param name="oldValue">The value before the change, which may be null for nullable types.</param>
  30. /// <param name="newValue">The value after the change, which may be null for nullable types.</param>
  31. public ValueChangedEventArgs (T oldValue, T newValue)
  32. {
  33. OldValue = oldValue;
  34. NewValue = newValue;
  35. }
  36. }