static public void DispatchEvent(this object target, KEvent evt) { var list = getHandlerList(target, evt.Type); if (null == list) return; evt.Sender = target; int i = 0; while (i < list.Count) { var handlerInfo = list[i]; //自动清除被回收的HandlerInfo对象 if (handlerInfo.Invoke(evt.clone()) == false) { list.RemoveAt(i); continue; } i++; } }
public virtual KEvent clone() { var evt = new KEvent(type, data); evt.sender = sender; return evt; }
static public void DispatchEvent(KEvent evt) { eventDispatcher.DispatchEvent(evt); }
public bool Invoke(KEvent evt) { if (Method.IsStatic == false) { if (TargetRef.IsAlive == false) return false; if (TargetRef.Target.ToString() == "null") return false; } try { Method.Invoke(TargetRef.Target, new[] { evt }); } catch (Exception e) { //Logger.LogException(e); } return true; }