static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); ApplicationEventDispatcher applicationEventDispatcher = null; MainProcess mainProcess = null; try { applicationEventDispatcher = new ApplicationEventDispatcher(); mainProcess = new MainProcess(applicationEventDispatcher); mainProcess.Start(); Application.Run(); } catch (Exception ex) { MessageBox.Show(ex.Message, @"Error!"); } finally { if (mainProcess != null) mainProcess.Dispose(); if (applicationEventDispatcher != null) applicationEventDispatcher.Dispose(); } }
public void Setup() { app = Substitute.For <Application>(); handler = new AppEventHandlerTester(); dispatcher = new ApplicationEventDispatcher(handler); dispatcher.Subscribe(app); }
private void CreateDispatchers(IApplicationEventsHandler handler) { ApplicationEventDispatcher = new ApplicationEventDispatcher(handler); B1FormDataEventDispatcher = new B1FormDataEventDispatcher(); B1MenuEventDispatcher = new B1MenuEventDispatcher(); B1ItemEventDispatcher = new B1ItemEventDispatcher(); B1RightClickEventDispatcher = new B1RightClickEventDispatcher(); B1LayoutKeyEventDispatcher = new B1LayoutKeyEventDispatcher(); }
/// <summary> /// Terminates the event managing system. /// </summary> public void Terminate() { B1ItemEventDispatcher.Unsubscribe(); B1MenuEventDispatcher.Unsubscribe(); B1RightClickEventDispatcher.Unsubscribe(); B1LayoutKeyEventDispatcher.Unsubscribe(); B1FormDataEventDispatcher.Unsubscribe(); ApplicationEventDispatcher.Unsubscribe(); }
public void GivenAnEventToDispatch_WhenDispatcherIsDisposed_ThrowsException() { // ARRANGE var dispatcher = new ApplicationEventDispatcher(); // ACT dispatcher.Dispose(); dispatcher.Dispatch(new SimpleEvent1()); // ASSERT }
public void GivenAnEventToDispatch_WhenAHandlerIsNotAttached_DoesNotThrowAnException() { // ARRANGE var dispatcher = new ApplicationEventDispatcher(); // ACT dispatcher.Dispatch(new SimpleEvent1()); dispatcher.Dispose(); // ASSERT }
private void StartEventDispatchers() { ApplicationEventDispatcher.Subscribe(application); B1ItemEventDispatcher.Subscribe(application); B1MenuEventDispatcher.Subscribe(application); B1RightClickEventDispatcher.Subscribe(application); B1FormDataEventDispatcher.Subscribe(application); B1LayoutKeyEventDispatcher.Subscribe(application); ApplicationEventDispatcher.EventHandlerError += OnEventHandlerError; B1MenuEventDispatcher.EventHandlerError += OnEventHandlerError; B1RightClickEventDispatcher.EventHandlerError += OnEventHandlerError; B1ItemEventDispatcher.EventHandlerError += OnEventHandlerError; B1FormDataEventDispatcher.OnEventHandlerError += OnEventHandlerError; B1LayoutKeyEventDispatcher.EventHandlerError += OnEventHandlerError; }
public void GivenAnEventToDispatch_WhenAHandlerIsAttached_CallsHandler() { // ARRANGE bool handlerCalled = false; ApplicationEventHandlerDelegate<SimpleEvent1> @delegate = delegate { handlerCalled = true; }; var dispatcher = new ApplicationEventDispatcher(); dispatcher.AddListener(@delegate); // ACT dispatcher.Dispatch(new SimpleEvent1()); dispatcher.Dispose(); // ASSERT Assert.IsTrue(handlerCalled); }
static void Main(string[] args) { // ARRANGE bool handlerCalled = false; ApplicationEventHandlerDelegate<SimpleEvent1> @delegate = delegate { handlerCalled = true; }; var dispatcher = new ApplicationEventDispatcher(); dispatcher.AddListener(@delegate); // ACT dispatcher.Dispatch(new SimpleEvent1()); dispatcher.Dispose(); // ASSERT Console.WriteLine("Handler called: {0}", handlerCalled); Console.ReadKey(); }
public static void Init() { applicationEventDispatcher = new ApplicationEventDispatcher(); }