2020-04-10 15:22:07 -07:00
|
|
|
|
// Copyright (c) Microsoft Corporation
|
|
|
|
|
|
// The Microsoft Corporation licenses this file to you under the MIT license.
|
|
|
|
|
|
// See the LICENSE file in the project root for more information.
|
|
|
|
|
|
|
2020-03-11 10:43:32 -07:00
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
|
using System.Runtime.CompilerServices;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Microsoft.PowerToys.Settings.UI.Helpers
|
|
|
|
|
|
{
|
|
|
|
|
|
public class Observable : INotifyPropertyChanged
|
|
|
|
|
|
{
|
|
|
|
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
|
|
|
|
|
|
2020-07-22 13:27:17 -07:00
|
|
|
|
protected void Set<T>(ref T storage, T value, [CallerMemberName] string propertyName = null)
|
2020-03-11 10:43:32 -07:00
|
|
|
|
{
|
|
|
|
|
|
if (Equals(storage, value))
|
|
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
storage = value;
|
2020-04-10 15:22:07 -07:00
|
|
|
|
OnPropertyChanged(propertyName);
|
2020-03-11 10:43:32 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2020-04-10 15:22:07 -07:00
|
|
|
|
protected void OnPropertyChanged(string propertyName) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
2020-03-11 10:43:32 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|