PropertyChangedTracker.cs 786 B

123456789101112131415161718192021222324252627282930
  1. // Copyright (c) The Avalonia Project. All rights reserved.
  2. // Licensed under the MIT license. See licence.md file in the project root for full license information.
  3. using System;
  4. using System.Collections.Generic;
  5. using System.ComponentModel;
  6. namespace Avalonia.Base.UnitTests.Collections
  7. {
  8. internal class PropertyChangedTracker
  9. {
  10. public PropertyChangedTracker(INotifyPropertyChanged obj)
  11. {
  12. Names = new List<string>();
  13. obj.PropertyChanged += PropertyChanged;
  14. }
  15. public List<string> Names { get; }
  16. public void Reset()
  17. {
  18. Names.Clear();
  19. }
  20. private void PropertyChanged(object sender, PropertyChangedEventArgs e)
  21. {
  22. Names.Add(e.PropertyName);
  23. }
  24. }
  25. }