mirror of
https://github.com/proxysu/ProxySU.git
synced 2024-11-26 15:16:08 +03:00
39 lines
1.0 KiB
C#
39 lines
1.0 KiB
C#
|
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
|
|||
|
}
|
|||
|
}
|