/// <summary> /// Triggers passed event at all registred handlers /// </summary> /// <param name="ev">The event</param> public void FireEvent(Event ev, IEventEmmiter source) { foreach (IEventHandler handler in _handlers) { handler.Notify(ev, source); } }
/// <summary> /// Atempts to forward the passed event to appropriate /// handler inside current class /// </summary> /// <param name="ev">The event</param> /// <param name="source">The emmiting object</param> /// <param name="handler">Object to handler the event</param> public static void Notify(this IEventHandler handler, Event ev, IEventEmmiter source) { if (handler.GetType().GetMethod("Handle" + ev.Name) != null) { // C# WTF? handler.GetType().GetMethod("Handle" + ev.Name).Invoke(handler, new object[] { ev, source }); } else { throw new System.NotImplementedException("This object doesn't have appropriate handler methods for event " + ev.Name); } }
/// <summary> /// Triggers passed event at all registred handlers /// </summary> /// <param name="ev">The event</param> public void FireEvent(Event ev, IEventEmmiter source) { foreach (IEventHandler handler in _handlers) { handler.Notify(ev,source); } }
public PaymentService(IEventEmmiter eventEmmiter) { _eventEmmiter = eventEmmiter; }
public BookingService(IEventEmmiter eventEmmiter) { _eventEmmiter = eventEmmiter; }