From e57938fbda9bff702004038f76d009422968bff5 Mon Sep 17 00:00:00 2001
From: alielie <alielie@git.com>
Date: 星期五, 06 十一月 2026 18:05:07 +0800
Subject: [PATCH] 提交代码
---
DeviceService/Entity/NotifyBase.cs | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 52 insertions(+), 0 deletions(-)
diff --git a/DeviceService/Entity/NotifyBase.cs b/DeviceService/Entity/NotifyBase.cs
new file mode 100644
index 0000000..e8f3be9
--- /dev/null
+++ b/DeviceService/Entity/NotifyBase.cs
@@ -0,0 +1,52 @@
+锘縰sing System.ComponentModel;
+using System.Runtime.CompilerServices;
+
+namespace DeviceService.Entity
+{
+ public abstract class NotifyBase : INotifyPropertyChanged
+ {
+ public event PropertyChangedEventHandler? PropertyChanged;
+
+ /// <summary>
+ /// 璁剧疆瀛楁鍊煎苟瑙﹀彂閫氱煡銆傚�间笌鏃у�肩浉绛夛紙鎴栧悓涓� null锛夋椂涓嶈Е鍙戯紝杩斿洖鏄惁鐪熸璧嬪�笺��
+ /// </summary>
+ protected bool SetProperty<T>(ref T field, T value, [CallerMemberName] string? propertyName = null)
+ {
+ if (Equals(field, value))
+ {
+ return false;
+ }
+
+ field = value;
+ OnPropertyChanged(propertyName);
+ return true;
+ }
+
+ /// <summary>瑙﹀彂褰撳墠灞炴�х殑閫氱煡锛宲ropertyName 缂虹渷涓鸿皟鐢ㄦ柟灞炴�у悕銆�</summary>
+ protected void OnPropertyChanged([CallerMemberName] string? propertyName = null)
+ {
+ RaiseChanged(propertyName);
+ }
+
+ /// <summary>鏄惧紡瑙﹀彂鎸囧畾灞炴�х殑閫氱煡锛堝渚濊禆灞炴�ц仈鍔級銆�</summary>
+ protected void OnPropertyChanged(string propertyName, params string[] morePropertyNames)
+ {
+ RaiseChanged(propertyName);
+ foreach (var name in morePropertyNames)
+ {
+ RaiseChanged(name);
+ }
+ }
+
+ /// <summary>閫氱煡鍏ㄩ儴灞炴�у凡鍙樻洿锛堥厤鍚� DataTemplate 鏃跺埛鏂版墍鏈夌粦瀹氾紝绛夋晥浜� Text 閫氱煡锛夈��</summary>
+ protected void RaiseAllChanged()
+ {
+ RaiseChanged(string.Empty);
+ }
+
+ private void RaiseChanged(string? propertyName)
+ {
+ PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName ?? string.Empty));
+ }
+ }
+}
--
Gitblit v1.9.1