IndeiBase.cs 1.1 KB

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