Exemple #1
0
        /// <summary>
        /// Adds the event listener.
        /// </summary>
        /// <returns>
        /// The event listener.
        /// </returns>
        /// <param name='aEventName_string'>
        /// If set to <c>true</c> a event type_string.
        /// </param>
        /// <param name='aEventDelegate'>
        /// If set to <c>true</c> a event delegate.
        /// </param>
        /// <param name='aEventDispatcherAddMode'>
        /// If set to <c>true</c> event listening mode.
        /// </param>
        public bool addEventListener(string aEventName_string, EventDelegate aEventDelegate, EventDispatcherAddMode aEventDispatcherAddMode)
        {
            //
            bool wasSuccessful_boolean = false;

            //
            object aIEventListener = _getArgumentsCallee(aEventDelegate);

            //
            if (aIEventListener != null && aEventName_string != null)
            {
                //    OUTER
                string keyForOuterHashTable_string = _getKeyForOuterHashTable(aEventName_string);
                if (!_eventListenerDatas_hashtable.ContainsKey(keyForOuterHashTable_string))
                {
                    _eventListenerDatas_hashtable.Add(keyForOuterHashTable_string, new Hashtable());
                }

                //    INNER
                Hashtable         inner_hashtable   = _eventListenerDatas_hashtable[keyForOuterHashTable_string] as Hashtable;
                EventListenerData eventListenerData = new EventListenerData(aIEventListener, aEventName_string, aEventDelegate, aEventDispatcherAddMode);
                //
                string keyForInnerHashTable_string = _getKeyForInnerHashTable(eventListenerData);
                if (inner_hashtable.Contains(keyForInnerHashTable_string))
                {
                    //THIS SHOULD *NEVER* HAPPEN - REMOVE AFTER TESTED WELL
                    Debug.Log("TODO (FIX THIS): Event Manager: Listener: " + keyForInnerHashTable_string + " is already in list for event: " + keyForOuterHashTable_string);
                }
                else
                {
                    //    ADD
                    inner_hashtable.Add(keyForInnerHashTable_string, eventListenerData);
                    wasSuccessful_boolean = true;
                    //Debug.Log ("    ADDED AT: " + keyForInnerHashTable_string + " = " +  eventListenerData);
                }
            }
            return(wasSuccessful_boolean);
        }
Exemple #2
0
 private string _getKeyForInnerHashTable(EventListenerData aEventListenerData)
 {
     //VERY UNIQUE - NICE!
     return(aEventListenerData.eventListener.GetType().FullName + "_" + aEventListenerData.eventListener.GetType().GUID + "_" + aEventListenerData.eventName + "_" + (aEventListenerData.eventDelegate as System.Delegate).Method.Name.ToString());
 }