Exemplo n.º 1
0
 internal static void SubscribeInternal(string eventName, InvokableActionBase action)
 {
     if (GlobalEventTable.TryGetValue(eventName, out List <InvokableActionBase> actions))
     {
         actions.Add(action);
     }
     else
     {
         actions = new List <InvokableActionBase>();
         actions.Add(action);
         GlobalEventTable.Add(eventName, actions);
     }
 }
Exemplo n.º 2
0
        internal static void SubscribeInternal(object obj, string eventName, InvokableActionBase action)
        {
            if (!EventTable.TryGetValue(obj, out Dictionary <string, List <InvokableActionBase> > handlers))
            {
                handlers = new Dictionary <string, List <InvokableActionBase> >();
                EventTable.Add(obj, handlers);
            }

            if (handlers.TryGetValue(eventName, out List <InvokableActionBase> actionList))
            {
                actionList.Add(action);
            }
            else
            {
                actionList = new List <InvokableActionBase>();
                actionList.Add(action);
                handlers.Add(eventName, actionList);
            }
        }