summaryrefslogtreecommitdiff
path: root/Decompiler/Gestor.Application.Helpers/NotifyPropertyChangedExtension.cs
blob: 2eb1bf4c5c8d9533a74173e3e5f8136935f9cf83 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.CompilerServices;

namespace Gestor.Application.Helpers;

public static class NotifyPropertyChangedExtension
{
	public static void MutateVerbose<TField>(this INotifyPropertyChanged instance, ref TField field, TField newValue, Action<PropertyChangedEventArgs> raise, [CallerMemberName] string propertyName = null)
	{
		if (!EqualityComparer<TField>.Default.Equals(field, newValue))
		{
			field = newValue;
			raise?.Invoke(new PropertyChangedEventArgs(propertyName));
		}
	}
}