using System; using System.Collections.Generic; namespace kt { public class PermTempAction { public void Add(Action callback, bool is_temp = false) { if (callback != null) { this.CallBackFlagDic[callback] = is_temp; } } public void Remove(Action callback) { if (callback != null) { this.CallBackFlagDic.Remove(callback); } } public void Clear() { this.CallBackFlagDic.Clear(); } public void Invoke(T0 t0) { List> list = new List>(); foreach (KeyValuePair, bool> keyValuePair in this.CallBackFlagDic) { Action key = keyValuePair.Key; if (keyValuePair.Value || key == null) { list.Add(key); } if (key != null) { key(t0); } } for (int i = 0; i < list.Count; i++) { this.CallBackFlagDic.Remove(list[i]); } } private Dictionary, bool> CallBackFlagDic = new Dictionary, bool>(); } }