From c5c7dcefacd7dac3c5d12e7f9d5f9ccc4b5d878b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=91=E5=8D=B4?= <479813005@qq.com> Date: Wed, 6 Dec 2023 11:20:22 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E5=91=BD=E5=90=8DKeyOrValueChanged?= =?UTF-8?q?=EF=BC=8C=E6=B6=88=E9=99=A4=E6=AD=A7=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Megumin.Explosion/Megumin/Class/Multiple.cs | 14 +++++++------- Megumin.Explosion/Megumin/Interface/IMultiple.cs | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Megumin.Explosion/Megumin/Class/Multiple.cs b/Megumin.Explosion/Megumin/Class/Multiple.cs index db80d41..7ef9737 100644 --- a/Megumin.Explosion/Megumin/Class/Multiple.cs +++ b/Megumin.Explosion/Megumin/Class/Multiple.cs @@ -14,7 +14,7 @@ public abstract partial class Multiple : IMultiple protected readonly Dictionary ElementDic = new Dictionary(); public event OnValueChanged ValueChanged; public event OnValueChanged<(K Key, V Value)> ValueChangedKV; - public event OnValueChanged<(K Key, V Value)> KeyValueChanged; + public event OnValueChanged<(K Key, V Value)> KeyOrValueChanged; public abstract K DefaultKey { get; } public abstract V DefaultValue { get; } @@ -52,7 +52,7 @@ protected virtual void ApplyValue(bool forceRaiseEvent = false) if (!flagV || !EqualsKey(oldKey, newKey) || forceRaiseEvent) { - OnKeyValueChanged((newKey, newValue), (oldKey, oldValue)); + OnKeyOrValueChanged((newKey, newValue), (oldKey, oldValue)); } } @@ -134,9 +134,9 @@ protected void OnValueChangedKV((K, V) newValue, (K, V) oldValue) ValueChangedKV?.Invoke(newValue, oldValue); } - protected void OnKeyValueChanged((K, V) newValue, (K, V) oldValue) + protected void OnKeyOrValueChanged((K, V) newValue, (K, V) oldValue) { - KeyValueChanged?.Invoke(newValue, oldValue); + KeyOrValueChanged?.Invoke(newValue, oldValue); } public V Add(K key, V value, bool forceRaiseEvent = false) @@ -230,17 +230,17 @@ internal void Subscribe(Multiple multiple, IObserver<(K Source, V Value)> { this.Multiple = multiple; this.Observer = observer; - Multiple.KeyValueChanged += this.OnKeyValueChanged; + Multiple.KeyOrValueChanged += this.OnKeyOrValueChanged; } - private void OnKeyValueChanged((K Key, V Value) newValue, (K Key, V Value) oldValue) + private void OnKeyOrValueChanged((K Key, V Value) newValue, (K Key, V Value) oldValue) { Observer.OnNext(newValue); } public void Dispose() { - Multiple.KeyValueChanged -= this.OnKeyValueChanged; + Multiple.KeyOrValueChanged -= this.OnKeyOrValueChanged; } } diff --git a/Megumin.Explosion/Megumin/Interface/IMultiple.cs b/Megumin.Explosion/Megumin/Interface/IMultiple.cs index 6c0a3cb..d22b022 100644 --- a/Megumin.Explosion/Megumin/Interface/IMultiple.cs +++ b/Megumin.Explosion/Megumin/Interface/IMultiple.cs @@ -65,6 +65,6 @@ public interface IMultiple /// /// 当前键值任一发生改变时被调用 /// - event OnValueChanged<(K Key, V Value)> KeyValueChanged; + event OnValueChanged<(K Key, V Value)> KeyOrValueChanged; } }