summaryrefslogtreecommitdiff
path: root/Codemerx/Gestor.Application/Helpers/NotifyPropertyChangedExtension.cs
blob: 955e38bfdfa3952e554597bf2b2184d780f4f0f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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))
			{
				return;
			}
			field = newValue;
			if (raise != null)
			{
				raise(new PropertyChangedEventArgs(propertyName));
			}
		}
	}
}