static LayeEvent() { TYPE.SetInvoke((LayeCallback)((state, ths, args) => { return (ths as LayeEvent).Fire(state, args) ? Laye.TRUE : Laye.FALSE; })); TYPE.PutInstanceMethod("connect", (LayeCallback)((state, ths, args) => { if (args.Length == 0 || args[0] == Laye.NULL) { state.RaiseException("bad argument #0 to connect, event handler cannot be null."); return Laye.NULL; } var arg = args[0]; var e = ths as LayeEvent; var handles = e.handles; foreach (var h in handles) if (h.handler == arg) return h; var handle = new LayeEventHandle(e, arg); return Laye.NULL; })); }
internal void DisconnectHandle(LayeEventHandle handle) { handles.Remove(handle); }