using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Runtime.CompilerServices; using System.Text; using System.Threading.Tasks; namespace PersonalMVVMToolkit { public class ObservableObject : INotifyPropertyChanged { #region Properties public event PropertyChangedEventHandler? PropertyChanged; protected virtual void OnPropertyChanged([CallerMemberName] string PropertyName = null) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(PropertyName)); protected virtual void SetProperty(T member, T value, Action action, [CallerMemberName] string propertyName = null) { if (EqualityComparer.Default.Equals(member, value)) return; action(value); OnPropertyChanged(propertyName); } protected virtual void SetProperty(ref T member, T value, [CallerMemberName] string propertyName = null) { if (EqualityComparer.Default.Equals(member, value)) return; member = value; OnPropertyChanged(propertyName); } #endregion } }