示例#1
0
        /// <summary>
        /// Adds the listener.
        /// </summary>
        /// <param name="eventName">Event name.</param>
        /// <param name="handler">Handler.</param>
        public static void AddListener(object eventName, Action <XLAF_Event> handler)
        {
            if (!listeners.ContainsKey(eventName))
            {
                listeners.Add(eventName, new List <XLAF_Event> ());
            }
            List <XLAF_Event> list = listeners [eventName];
            XLAF_Event        e    = new XLAF_Event(eventName);

            e.action = handler;
            list.Add(e);
        }
示例#2
0
        /// <summary>
        /// Dispatch the XLAF_Event.
        /// </summary>
        /// <param name="e">XLAF_Event.</param>
        public static void Dispatch(XLAF_Event e)
        {
            if (e.name == null)
            {
                XLAFInnerLog.Error("Event is not right", e);
                return;
            }
            List <XLAF_Event> list;

            if (!listeners.TryGetValue(e.name, out list))
            {
                XLAFInnerLog.Warning("No callback functions names ", e.name);
                return;
            }
            for (int i = 0; i < list.Count; i++)
            {
                if (list [i].action != null)
                {
                    list [i].data = e.data;
                    list [i].action(list [i]);
                }
            }
        }
示例#3
0
 /// <summary>
 /// Dispatch the XLAF_Event.
 /// </summary>
 /// <param name="e">Event.</param>
 public virtual void OnXLAFEvent(XLAF_Event e)
 {
 }