예제 #1
0
        protected virtual void OnRaiseCustomEvent(CustomEvent e)
        {
            EventHandler<CustomEvent> handler = RaiseCustomEvent;

            if (handler != null)
            {
                e.Message += String.Format(" at {0}", DateTime.Now.ToString());
                handler(this, e);
            }
        }
예제 #2
0
        protected virtual void OnRaiseCustomEvent(CustomEvent e)
        {
            EventHandler <CustomEvent> handler = RaiseCustomEvent;

            if (handler != null)
            {
                e.Message += String.Format(" at {0}", DateTime.Now.ToString());
                handler(this, e);
            }
        }
예제 #3
0
        public bool RemoveListener(CustomEvent eventName, EventDelegate oldListener)
        {
            if (listeners.ContainsKey(eventName))
            {
                listeners[eventName] -= oldListener;

                return(true);
            }

            return(false);
        }
예제 #4
0
 public void AddListener(CustomEvent eventName, EventDelegate newListener)
 {
     if (listeners.ContainsKey(eventName))
     {
         listeners[eventName] += newListener;
     }
     else
     {
         listeners.Add(eventName, newListener);
     }
 }
예제 #5
0
        public bool CallEvent(CustomEvent eventName, EventArgument argument)
        {
            if (listeners.ContainsKey(eventName))
            {
                EventDelegate eventDelegate;
                listeners.TryGetValue(eventName, out eventDelegate);

                eventDelegate(argument);

                return(true);
            }

            return(false);
        }
예제 #6
0
 void HandleCustomEvent(object sender, CustomEvent e)
 {
     Console.WriteLine(id + " received: {0}", e.Message);
 }
 void HandleCustomEvent(object sender, CustomEvent e)
 {
     Console.WriteLine(id + " received: {0}", e.Message);
 }
 public override void customEventOccured(CustomEvent ce)
 {
     Console.WriteLine("Object with key: " + ce.Key + " has raised custom event.");
 }