2023-09-04 11:51:05 +08:00
|
|
|
using System;
|
2023-04-13 11:51:03 +08:00
|
|
|
using System.ComponentModel;
|
|
|
|
using System.Runtime.CompilerServices;
|
|
|
|
|
|
|
|
namespace Sicentury.Core
|
|
|
|
{
|
2023-09-04 11:51:05 +08:00
|
|
|
[Serializable]
|
2023-04-13 11:51:03 +08:00
|
|
|
public abstract class BindableBase : INotifyPropertyChanged
|
|
|
|
{
|
|
|
|
|
|
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
|
|
|
|
|
|
|
protected virtual void Set<T>(ref T storage, T value, [CallerMemberName] string propertyName = null)
|
|
|
|
{
|
|
|
|
if (Equals(storage, value))
|
|
|
|
return;
|
|
|
|
|
|
|
|
storage = value;
|
|
|
|
OnPropertyChanged(propertyName);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected void OnPropertyChanged([CallerMemberName] string propertyName = null)
|
|
|
|
{
|
|
|
|
PropertyChangedEventHandler eventHandler = this.PropertyChanged;
|
|
|
|
eventHandler?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|