示例#1
0
 public void Unsubscribe(NuiWindowToken token, Action <ModuleEvents.OnNuiEvent> handler)
 {
     if (eventHandlers.TryGetValue(token.Player, out Dictionary <int, Action <ModuleEvents.OnNuiEvent> >?playerHandlers))
     {
         if (playerHandlers.TryGetValue(token.Token, out Action <ModuleEvents.OnNuiEvent>?existingHandler))
         {
             existingHandler -= handler;
             if (existingHandler == null)
             {
                 playerHandlers.Remove(token.Token);
             }
         }
     }
 }
示例#2
0
        public void Subscribe(NuiWindowToken token, Action <ModuleEvents.OnNuiEvent> handler)
        {
            if (!eventHandlers.TryGetValue(token.Player, out Dictionary <int, Action <ModuleEvents.OnNuiEvent> >?playerHandlers))
            {
                playerHandlers = new Dictionary <int, Action <ModuleEvents.OnNuiEvent> >();
                eventHandlers[token.Player] = playerHandlers;
            }

            if (playerHandlers.ContainsKey(token.Token))
            {
                playerHandlers[token.Token] += handler;
            }
            else
            {
                playerHandlers[token.Token] = handler;
            }
        }