mirror of
https://github.com/bitwarden/android.git
synced 2025-01-09 17:57:34 +03:00
32 lines
931 B
C#
32 lines
931 B
C#
|
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;
|
|||
|
|
|||
|
protected bool SetProperty<T>(ref T backingStore, T value, [CallerMemberName]string propertyName = "",
|
|||
|
Action onChanged = null)
|
|||
|
{
|
|||
|
if(EqualityComparer<T>.Default.Equals(backingStore, value))
|
|||
|
{
|
|||
|
return false;
|
|||
|
}
|
|||
|
|
|||
|
backingStore = value;
|
|||
|
onChanged?.Invoke();
|
|||
|
OnPropertyChanged(propertyName);
|
|||
|
return true;
|
|||
|
}
|
|||
|
|
|||
|
protected void OnPropertyChanged([CallerMemberName] string propertyName = "")
|
|||
|
{
|
|||
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
|||
|
}
|
|||
|
}
|
|||
|
}
|