main
 1using MoMoney.Presentation;
 2using MoMoney.Presentation.Core;
 3using momoney.presentation.model.eventing;
 4using momoney.presentation.views;
 5using MoMoney.Service.Infrastructure.Eventing;
 6
 7namespace momoney.presentation.presenters
 8{
 9    public interface IUnhandledErrorPresenter : IModule, IPresenter,
10                                                IEventSubscriber<UnhandledErrorOccurred>
11    {
12        void restart_application();
13    }
14
15    public class UnhandledErrorPresenter : IUnhandledErrorPresenter
16    {
17        readonly IUnhandledErrorView view;
18        readonly IEventAggregator broker;
19        readonly IRestartCommand restart;
20
21        public UnhandledErrorPresenter(IUnhandledErrorView view, IEventAggregator broker, IRestartCommand command)
22        {
23            this.view = view;
24            restart = command;
25            this.broker = broker;
26        }
27
28        public void run()
29        {
30            view.attach_to(this);
31            broker.subscribe_to(this);
32        }
33
34        public void notify(UnhandledErrorOccurred message)
35        {
36            view.display(message.error);
37        }
38
39        public void restart_application()
40        {
41            restart.run();
42        }
43    }
44}