IndeiBase.cs 991 B

1234567891011121314151617181920212223242526272829
  1. using System;
  2. using System.Collections;
  3. using System.ComponentModel;
  4. using System.Runtime.CompilerServices;
  5. using Avalonia.UnitTests;
  6. namespace Avalonia.Base.UnitTests.Data.Core
  7. {
  8. internal abstract class IndeiBase : NotifyingBase, INotifyDataErrorInfo
  9. {
  10. private EventHandler<DataErrorsChangedEventArgs> _errorsChanged;
  11. public abstract bool HasErrors { get; }
  12. public int ErrorsChangedSubscriptionCount { get; private set; }
  13. public event EventHandler<DataErrorsChangedEventArgs> ErrorsChanged
  14. {
  15. add { _errorsChanged += value; ++ErrorsChangedSubscriptionCount; }
  16. remove { _errorsChanged -= value; --ErrorsChangedSubscriptionCount; }
  17. }
  18. public abstract IEnumerable GetErrors(string propertyName);
  19. protected void RaiseErrorsChanged([CallerMemberName] string propertyName = "")
  20. {
  21. _errorsChanged?.Invoke(this, new DataErrorsChangedEventArgs(propertyName));
  22. }
  23. }
  24. }