public void Add(Guid EventID, Del_HandleEvent EventHandler, enPriority HandlePriority)
        {
            //Case:Exist eventId matched ListenerGroup
            if (m_Listeners.TryGetValue(EventID, out var ListenerGroup))
            {
                //Case: Exist priority matched Listener List
                //Act: Just Add Listener
                if (ListenerGroup.TryGetValue(HandlePriority, out var ListenerList))
                {
                    m_PrioritiesDic.Add(EventHandler, HandlePriority);

                    ListenerList.Add(EventHandler);
                }
                //Case: no priority matched Listener List
                //Act: Make a instnace of Listener list first and Add Listener
                else
                {
                    ListenerList = new List <Del_HandleEvent>();

                    m_PrioritiesDic.Add(EventHandler, HandlePriority);

                    ListenerList.Add(EventHandler);

                    ListenerGroup.Add(HandlePriority, ListenerList);
                }
            }
            //Case: no eventId matched ListenerGroup
            else
            {
                //Make an instance of ListenerGroup
                ListenerGroup = new SortedDictionary <enPriority, List <Del_HandleEvent> >();

                //Make an instance of ListenerList
                List <Del_HandleEvent> ListenerList = new List <Del_HandleEvent>();

                //Save to dictionary
                m_PrioritiesDic.Add(EventHandler, HandlePriority);

                //add Handler
                ListenerList.Add(EventHandler);

                //add ListenerList
                ListenerGroup.Add(HandlePriority, ListenerList);

                //add ListenerGroup
                m_Listeners.Add(EventID, ListenerGroup);
            }
        }
Esempio n. 2
0
 public void SubScribe(Guid EventID, Del_HandleEvent EventHandler
                       , enPriority HandlePriority)
 {
     //Case: Exist listenerStorage
     if (m_EventListeners.TryGetValue(EventID,
                                      out ListenerStorage tempListeners))
     {
         tempListeners.Add(EventID, EventHandler, HandlePriority);
     }
     //Case: No listenerStorage
     else
     {
         //Make a new instance of  this event listeneres
         tempListeners = new ListenerStorage();
         //add this event Handler
         tempListeners.Add(EventID, EventHandler, HandlePriority);
         //save this event listeners
         m_EventListeners.Add(EventID, tempListeners);
     }
 }
 public void SubsribeEvent(Guid EventID, Del_HandleEvent handler, enPriority priority = enPriority.Lowest)
 {
     m_EventHelper.Subscribe(EventID, handler, priority);
 }
Esempio n. 4
0
 public void Subscribe(Guid EventID, Del_HandleEvent handler, enPriority HandlePriority)
 {
     m_EventCenter.SubScribe(EventID, handler, HandlePriority);
 }
 protected void SubscribeEvent(Guid EventID, Del_HandleEvent handler, enPriority priority = enPriority.Lowest)
 {
     m_EventHandlers.Add(new KeyValuePair <Guid, Del_HandleEvent>(EventID, handler));
     m_Communicator.SubsribeEvent(EventID, handler, priority);
 }