2019-03-29 12:52:57 -04:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Runtime.CompilerServices;
|
|
|
|
|
|
|
|
|
|
namespace Bit.Core.Utilities
|
|
|
|
|
{
|
|
|
|
|
public abstract class ExtendedViewModel : INotifyPropertyChanged
|
|
|
|
|
{
|
|
|
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
|
|
|
|
|
2019-03-29 16:52:57 -04:00
|
|
|
|
protected bool SetProperty<T>(ref T backingStore, T value, Action onChanged = null,
|
|
|
|
|
[CallerMemberName]string propertyName = "")
|
2019-03-29 12:52:57 -04:00
|
|
|
|
{
|
|
|
|
|
if(EqualityComparer<T>.Default.Equals(backingStore, value))
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
backingStore = value;
|
2019-03-29 16:52:57 -04:00
|
|
|
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
2019-03-29 12:52:57 -04:00
|
|
|
|
onChanged?.Invoke();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|