Skip to content

Commit

Permalink
重命名KeyOrValueChanged,消除歧义
Browse files Browse the repository at this point in the history
  • Loading branch information
KumoKyaku committed Dec 6, 2023
1 parent 748132c commit c5c7dce
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions Megumin.Explosion/Megumin/Class/Multiple.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public abstract partial class Multiple<K, V> : IMultiple<K, V>
protected readonly Dictionary<K, V> ElementDic = new Dictionary<K, V>();
public event OnValueChanged<V> 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; }
Expand Down Expand Up @@ -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));
}
}

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -230,17 +230,17 @@ internal void Subscribe(Multiple<K, V> 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;
}
}

Expand Down
2 changes: 1 addition & 1 deletion Megumin.Explosion/Megumin/Interface/IMultiple.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,6 @@ public interface IMultiple<K, V>
/// <summary>
/// 当前键值任一发生改变时被调用
/// </summary>
event OnValueChanged<(K Key, V Value)> KeyValueChanged;
event OnValueChanged<(K Key, V Value)> KeyOrValueChanged;
}
}

0 comments on commit c5c7dce

Please sign in to comment.