SOMS/Yunda.SOMS.DataMonitoringServer.Viewport/Domain/Helper/NotifyPropertyChangedExtension.cs
2024-08-21 16:50:14 +08:00

17 lines
667 B
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.CompilerServices;
namespace Yunda.SOMS.DataMonitoringServer.Viewport.Domain.Helper
{
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;
raise?.Invoke(new PropertyChangedEventArgs(propertyName));
}
}
}