mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
7b005a1c54
Made a common base class that implements INotifyPropertyChanged. Also implements a RaiseAndSetIfChanged call that streamlines property definitions. Some other various cleaning
31 lines
856 B
C#
31 lines
856 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Linq;
|
|
using System.Runtime.CompilerServices;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Wabbajack
|
|
{
|
|
public class ViewModel : INotifyPropertyChanged
|
|
{
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
|
|
|
protected void RaisePropertyChanged([CallerMemberName] string name = null)
|
|
{
|
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
|
|
}
|
|
|
|
protected void RaiseAndSetIfChanged<T>(
|
|
ref T item,
|
|
T newItem,
|
|
[CallerMemberName] string propertyName = null)
|
|
{
|
|
if (EqualityComparer<T>.Default.Equals(item, newItem)) return;
|
|
item = newItem;
|
|
this.RaisePropertyChanged(propertyName);
|
|
}
|
|
}
|
|
}
|