public void CherryEventSimpleTest()
        {
            const string eventName = "event Name";

            var eventsProvider = new TestEventsProvider();
            var sentArgs = new CherryEventArgs();
            var cherryEvent = new CherryEvent(eventName);
            Assert.AreEqual(eventName, cherryEvent.Name);
            cherryEvent.Fire(null);

            bool listenerAdded = cherryEvent.AddListener(new CherryEventListener(
                eventName,
                ea => { }));
            Assert.IsTrue(listenerAdded);

            cherryEvent.Fire(sentArgs);
        }
        public void Fire(CherryEventArgs eventArgs)
        {
            try
            {
                Trace.WriteLine(string.Format("Firing event: '{0}'", this.Name));

                // We are cloning the listeners collection because it can be changed by one of the listeners.
                foreach (var listener in this.listeners.ToList())
                {
                    Trace.WriteLine(string.Format("Invoking event listener from assembly {0}", listener.ContainerAssembly));
                    listener.Handle(eventArgs);
                }

                Trace.WriteLine(string.Format("Event fired: '{0}'", this.Name));
            }
            catch (Exception ex)
            {
                Trace.WriteLine(string.Format("Exception on event '{0}' fire {1}\n{2}", this.Name, ex.Message, ex.StackTrace));
            }
        }
 public void Handle(CherryEventArgs args)
 {
     this.callbackHandler(args);
 }