Ejemplo n.º 1
0
 public bool UnregisterHotKey(VgcApis.Interfaces.Lua.ILuaMailBox mailbox, string handle)
 {
     if (postOffice.ValidateMailBox(mailbox) &&
         hotkeys.TryGetValue(handle, out var mb) &&
         ReferenceEquals(mb, mailbox) &&
         hotkeys.TryRemove(handle, out _))
     {
         return(luaApis.UnregisterHotKey(handle));
     }
     return(false);
 }
Ejemplo n.º 2
0
        public bool UnregisterCoreEvent(VgcApis.Interfaces.Lua.ILuaMailBox mailbox, string handle)
        {
            if (!postOffice.ValidateMailBox(mailbox))
            {
                return(false);
            }

            if (coreEvHooks.TryRemove(handle, out var evhook))
            {
                try
                {
                    var coreServ = evhook.coreServCtrl;
                    var handler  = evhook.evHandler;
                    switch (evhook.evType)
                    {
                    case CoreEvTypes.CoreStart:
                        coreServ.OnCoreStart -= handler;
                        break;

                    case CoreEvTypes.CoreStop:
                        coreServ.OnCoreStop -= handler;
                        break;

                    case CoreEvTypes.CoreClosing:
                        coreServ.OnCoreStop -= handler;
                        break;

                    case CoreEvTypes.PropertyChanged:
                        coreServ.OnPropertyChanged -= handler;
                        break;

                    default:
                        return(false);
                    }
                    return(true);
                }
                catch { }
            }
            return(false);
        }