1
0
mirror of https://github.com/proxysu/ProxySU.git synced 2024-11-26 15:16:08 +03:00
ProxySU/ProxySU_Core/ViewModels/BaseModel.cs

39 lines
1.0 KiB
C#
Raw Normal View History

2021-04-05 05:22:43 +03:00
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProxySU_Core.ViewModels
{
public class BaseViewModel2 : INotifyPropertyChanged
{
protected bool SetProperty<T>(ref T backingStore, T value,
string propertyName = "",
Action onChanged = null)
{
if (EqualityComparer<T>.Default.Equals(backingStore, value))
return false;
backingStore = value;
onChanged?.Invoke();
OnPropertyChanged(propertyName);
return true;
}
#region INotifyPropertyChanged
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged(string propertyName = "")
{
var changed = PropertyChanged;
if (changed == null)
return;
changed.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
#endregion
}
}