static void Main(string[] args) { Console.WriteLine("SecondExampleApp starting ..."); EventAggregator aggregator = new EventAggregator(); var myAnotherExampleEvent = new MyAnotherExampleEvent(); aggregator.GlobalPublish(myAnotherExampleEvent); var myExampleEvent = new MyExampleEvent(); while (true) { Console.WriteLine("Press 's' to broadcast event...\n"); ConsoleKeyInfo key = Console.ReadKey(); if (key.KeyChar.Equals('s')) { aggregator.GlobalPublish(myExampleEvent); } else { break; } } var myOneOtherExampleEvent = new MyOneOtherExampleEvent(); aggregator.GlobalPublish(myOneOtherExampleEvent); Console.WriteLine("Press any kay to close."); Console.ReadKey(); }
public void Handle(MyExampleEvent receivedEvent) { Console.WriteLine("\nAll example listener handle MyExampleEvent event."); }
private void OnParentCompAttrEvent(MyExampleEvent ev) { Debug.LogFormat( "Parent Component Attribute Event Triggered: Integer: {0} GameObject: {1} Was Global Event?: {2}", ev.anIntProperty, ev.anObjectProperty == null ? "null" : ev.anObjectProperty.name, ev.wasGlobal); }
private bool ListenerFunctionTerminable(MyExampleEvent ev) { Debug.LogFormat( "Listener Function Terminable Invoked: Integer: {0} GameObject: {1} Was Global Event?: {2}", ev.anIntProperty, ev.anObjectProperty == null ? "null" : ev.anObjectProperty.name, ev.wasGlobal); // We arbitrarily decide to terminate if the int property is < 5. return ev.anIntProperty < 5; }
private void ListenerFunction(MyExampleEvent ev) { Debug.LogFormat( "ListenerFunction Invoked: Integer: {0} GameObject: {1} Was Global Event?: {2}", ev.anIntProperty, ev.anObjectProperty == null ? "null" : ev.anObjectProperty.name, ev.wasGlobal); }