20240301_JSEQ_upperpc/JiangsuEarthquake_test/JiangsuEarthquake/Common/NotifyBase.cs
XuMin 748090f317 修改部分:
1 地震仪告警记录中故障次数隐藏;电力载波机和光电交换机的供电状态隐藏;
2 除漏水和保护板事件的数据按照浮点数解析,别的按照整数解析;
3 解决TCP Server和Client存在的问题,包括无法监测到客户端连接,无法监测到服务端断开等问题;
2024-08-13 14:35:33 +08:00

45 lines
1.6 KiB
C#

using GalaSoft.MvvmLight;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
namespace JiangsuEarthquake.Common
{
public class NotifyBase : ObservableObject,INotifyPropertyChanged
{
public event PropertyChangedEventHandler? PropertyChanged;
//[CallerMemberName]string propName = "" 设置一个默认值 提高容错性
public void DoNotify([CallerMemberName] string propName = "")
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propName));
}
/// <summary>
/// Sets property if it does not equal existing value. Notifies listeners if change occurs.
/// </summary>
/// <typeparam name="T">Type of property.</typeparam>
/// <param name="member">The property's backing field.</param>
/// <param name="value">The new value.</param>
/// <param name="propertyName">Name of the property used to notify listeners. This
/// value is optional and can be provided automatically when invoked from compilers
/// that support <see cref="CallerMemberNameAttribute"/>.</param>
protected virtual bool SetProperty<T>(ref T member, T value, [CallerMemberName] string? propertyName = null)
{
if (EqualityComparer<T>.Default.Equals(member, value))
{
return false;
}
member = value;
DoNotify(propertyName);
return true;
}
}
}