Exemple #1
0
        public bool removeWatcher(string watherName)
        {
            if (string.IsNullOrEmpty(watherName))
            {
                return(false);
            }
            EventWatcher item = (from e in this.listEventWatcher
                                 where e.objName == watherName
                                 select e).FirstOrDefault <EventWatcher>();

            if (item == null)
            {
                return(false);
            }
            return(this.listEventWatcher.Remove(item));
        }
Exemple #2
0
        public bool removeWatcher(EventHandlerDelegate eventHandler)
        {
            if (eventHandler == null)
            {
                return(false);
            }
            EventWatcher item = (from e in this.listEventWatcher
                                 where e.mHandler == eventHandler
                                 select e).FirstOrDefault <EventWatcher>();

            if (item == null)
            {
                return(false);
            }
            return(this.listEventWatcher.Remove(item));
        }
Exemple #3
0
 public static bool removeEventWatcher(EventConst eventID, EventWatcher watcher)
 {
     lock (lockEventMap)
     {
         if ((watcher == null) || !mapEventObject.ContainsKey(eventID))
         {
             Log.e("EventCenter", "remove event watcher failed,  eventid= " + eventID);
             return(false);
         }
         EventObject obj2 = mapEventObject[eventID];
         bool        flag = obj2.removeWatcher(watcher);
         if (obj2.getCount() == 0)
         {
             mapEventObject.Remove(eventID);
         }
         return(flag);
     }
 }
Exemple #4
0
 public static bool registerEventWatcher(EventConst eventID, EventWatcher eventWatcher)
 {
     if ((eventWatcher == null) || (eventWatcher.mHandler == null))
     {
         Log.e("EventCenter", "register event id without watcher, ignored.  eventid = " + eventID);
         return(false);
     }
     lock (lockEventMap)
     {
         EventObject obj2;
         if (mapEventObject.ContainsKey(eventID))
         {
             obj2 = mapEventObject[eventID];
         }
         else
         {
             obj2 = new EventObject(eventID);
             mapEventObject.Add(eventID, obj2);
         }
         return(obj2.addWatcher(eventWatcher));
     }
 }
Exemple #5
0
        public static bool registerEventHandler(EventConst eventID, EventHandlerDelegate eventHandler)
        {
            EventWatcher eventWatcher = new EventWatcher(null, null, eventHandler);

            return(registerEventWatcher(eventID, eventWatcher));
        }
Exemple #6
0
        public static bool registerEventWatcher(EventConst eventID, string watchName, EventHandlerDelegate eventHandler)
        {
            EventWatcher eventWatcher = new EventWatcher(watchName, eventHandler);

            return(registerEventWatcher(eventID, eventWatcher));
        }