Commit 67f4533

unknown <mo@.(none)>
2010-01-24 20:20:58
removed more interfaces, and refactored how the application controller functions.
1 parent b01eb2a
product/Boot/Modules/ApplicationMenuModule.cs
@@ -20,7 +20,7 @@ namespace MoMoney.Modules
         public void run()
         {
             broker.subscribe(this);
-            command.run<IApplicationMenuPresenter>();
+            command.run<ApplicationMenuPresenter>();
         }
 
         public void notify(NewProjectOpened message)
product/Boot/Modules/ApplicationShellModule.cs
@@ -19,7 +19,7 @@ namespace MoMoney.Modules
 
         public void run()
         {
-            command.run<IApplicationShellPresenter>();
+            command.run<ApplicationShellPresenter>();
         }
     }
 }
\ No newline at end of file
product/Boot/Modules/ToolbarModule.cs
@@ -20,7 +20,7 @@ namespace MoMoney.Modules
         public void run()
         {
             broker.subscribe(this);
-            command.run<IToolbarPresenter>();
+            command.run<ToolBarPresenter>();
         }
 
         public void notify(NewProjectOpened message)
product/Presentation/Core/ApplicationController.cs
@@ -1,4 +1,3 @@
-using gorilla.commons.utility;
 using MoMoney.Presentation.Views;
 
 namespace MoMoney.Presentation.Core
@@ -8,28 +7,20 @@ namespace MoMoney.Presentation.Core
         void run<Presenter>() where Presenter : IPresenter;
     }
 
-    public class ApplicationController : IApplicationController, ParameterizedCommand<IPresenter>
+    public class ApplicationController : IApplicationController
     {
         IShell shell;
-        PresenterFactory factory;
+        PresenterFactory presenter_factory;
 
-        public ApplicationController(IShell shell, PresenterFactory factory)
+        public ApplicationController(IShell shell, PresenterFactory presenter_factory)
         {
-            this.factory = factory;
+            this.presenter_factory = presenter_factory;
             this.shell = shell;
         }
 
         public void run<Presenter>() where Presenter : IPresenter
         {
-            run(factory.create<Presenter>());
-        }
-
-        public void run(IPresenter presenter)
-        {
-            presenter.present();
-            if (!presenter.is_an_implementation_of<IContentPresenter>()) return;
-
-            shell.add(presenter.downcast_to<IContentPresenter>().View);
+            presenter_factory.create<Presenter>().present(shell);
         }
     }
 }
\ No newline at end of file
product/Presentation/Core/ApplicationControllerSpecs.cs
@@ -1,27 +1,27 @@
 using developwithpassion.bdd.contexts;
 using Gorilla.Commons.Testing;
-using momoney.presentation.views;
 using MoMoney.Presentation.Views;
 
 namespace MoMoney.Presentation.Core
 {
-    [Concern(typeof (ApplicationController))]
-    public abstract class behaves_like_an_application_controller :
-        concerns_for<IApplicationController, ApplicationController>
+    public class ApplicationControllerSpecs
     {
-        context c = () =>
+        [Concern(typeof (ApplicationController))]
+        public abstract class concern : concerns_for<IApplicationController, ApplicationController>
+        {
+            context c = () =>
                         {
                             presenter_factory = the_dependency<PresenterFactory>();
                             shell = the_dependency<IShell>();
                         };
 
-        static protected IShell shell;
-        static protected PresenterFactory presenter_factory;
-    }
+            static protected IShell shell;
+            static protected PresenterFactory presenter_factory;
+        }
 
-    public class when_the_application_controller_is_asked_to_run_a_presenter : behaves_like_an_application_controller
-    {
-        context c = () =>
+        public class when_the_application_controller_is_asked_to_run_a_presenter : concern
+        {
+            context c = () =>
                         {
                             implementation_of_the_presenter = an<IPresenter>();
                             presenter_factory
@@ -29,28 +29,12 @@ namespace MoMoney.Presentation.Core
                                 .it_will_return(implementation_of_the_presenter);
                         };
 
-        because b = () => sut.run<IPresenter>();
-
-        it should_initialize_the_presenter_to_run = () => implementation_of_the_presenter.was_told_to(p => p.present());
-
-        static IPresenter implementation_of_the_presenter;
-    }
-
-    public class when_initializing_a_presenter_for_that_presents_a_content_view : behaves_like_an_application_controller
-    {
-        it should_add_the_content_view_to_the_window_shell = () => shell.was_told_to(x => x.add(view));
-
-        context c = () =>
-                        {
-                            view = an<IDockedContentView>();
-                            var presenter = an<IContentPresenter>();
-
-                            presenter_factory.is_told_to(r => r.create<IContentPresenter>()).it_will_return(presenter);
-                            presenter.is_told_to(x => x.View).it_will_return(view);
-                        };
+            because b = () => sut.run<IPresenter>();
 
-        because b = () => sut.run<IContentPresenter>();
+            it should_initialize_the_presenter_to_run =
+                () => implementation_of_the_presenter.was_told_to(p => p.present(shell));
 
-        static IDockedContentView view;
+            static IPresenter implementation_of_the_presenter;
+        }
     }
 }
\ No newline at end of file
product/Presentation/Core/CachedPresenterFactory.cs
@@ -9,16 +9,20 @@ namespace MoMoney.Presentation.Core
 
     public class CachedPresenterFactory : PresenterFactory
     {
-        readonly IPresenterRegistry registered_presenters;
+        IPresenterRegistry registered_presenters;
+        ViewFactory view_factory;
 
-        public CachedPresenterFactory(IPresenterRegistry registered_presenters)
+        public CachedPresenterFactory(IPresenterRegistry registered_presenters, ViewFactory view_factory)
         {
             this.registered_presenters = registered_presenters;
+            this.view_factory = view_factory;
         }
 
         public Presenter create<Presenter>() where Presenter : IPresenter
         {
-            return registered_presenters.find_an_implementation_of<IPresenter, Presenter>();
+            var presenter = registered_presenters.find_an_implementation_of<IPresenter, Presenter>();
+            view_factory.create_for<Presenter>().attach_to(presenter);
+            return presenter;
         }
     }
 }
\ No newline at end of file
product/Presentation/Core/CachingViewFactory.cs
@@ -0,0 +1,25 @@
+using gorilla.commons.utility;
+using momoney.presentation.views;
+
+namespace MoMoney.Presentation.Core
+{
+    public interface ViewFactory
+    {
+        IView<Presenter> create_for<Presenter>() where Presenter : IPresenter;
+    }
+
+    public class CachingViewFactory : ViewFactory
+    {
+        Registry<IView> views;
+
+        public CachingViewFactory(Registry<IView> views)
+        {
+            this.views = views;
+        }
+
+        public IView<Presenter> create_for<Presenter>() where Presenter : IPresenter
+        {
+            return views.find_an_implementation_of<IView, IView<Presenter>>();
+        }
+    }
+}
\ No newline at end of file
product/Presentation/Core/ContentPresenter.cs
@@ -1,4 +1,5 @@
 using momoney.presentation.views;
+using MoMoney.Presentation.Views;
 
 namespace MoMoney.Presentation.Core
 {
@@ -11,24 +12,14 @@ namespace MoMoney.Presentation.Core
             this.view = view;
         }
 
-        IDockedContentView IContentPresenter.View
+        protected virtual void present()
         {
-            get { return view; }
         }
 
-        public abstract void present();
-
-        public virtual void activate()
-        {
-        }
-
-        public virtual void deactivate()
-        {
-        }
-
-        public virtual bool can_close()
+        public void present(IShell shell)
         {
-            return true;
+            shell.add(view);
+            present();
         }
     }
 }
\ No newline at end of file
product/Presentation/Core/IContentPresenter.cs
@@ -1,9 +1,6 @@
-using momoney.presentation.views;
-
 namespace MoMoney.Presentation.Core
 {
     public interface IContentPresenter : IPresenter
     {
-        IDockedContentView View { get; }
     }
 }
\ No newline at end of file
product/Presentation/Core/IPresenter.cs
@@ -1,7 +1,9 @@
+using MoMoney.Presentation.Views;
+
 namespace MoMoney.Presentation.Core
 {
     public interface IPresenter
     {
-        void present();
+        void present(IShell shell);
     }
 }
\ No newline at end of file
product/Presentation/Model/Menu/File/SaveChangesCommand.cs
@@ -4,6 +4,7 @@ using MoMoney.Presentation.Core;
 using momoney.presentation.model.menu.file;
 using MoMoney.Presentation.Model.Projects;
 using momoney.presentation.views;
+using MoMoney.Presentation.Views;
 
 namespace MoMoney.Presentation.Model.Menu.File
 {
@@ -37,7 +38,7 @@ namespace MoMoney.Presentation.Model.Menu.File
             this.view = view;
         }
 
-        public void present()
+        public void present(IShell shell)
         {
             throw new NotImplementedException();
         }
product/Presentation/Model/Menu/Help/HelpMenu.cs
@@ -37,7 +37,7 @@ namespace MoMoney.Presentation.Model.Menu.Help
                 .a_menu_item()
                 .named("Check For Updates...")
                 .represented_by(ApplicationIcons.Update)
-                .that_executes(() => command.run<ICheckForUpdatesPresenter>())
+                .that_executes(() => command.run<CheckForUpdatesPresenter>())
                 .build();
 
             yield return Create.a_menu_item_separator();
product/Presentation/Presenters/AboutTheApplicationPresenter.cs
@@ -8,9 +8,5 @@ namespace momoney.presentation.presenters
         public AboutTheApplicationPresenter(IAboutApplicationView view) : base(view)
         {
         }
-
-        public override void present()
-        {
-        }
     }
 }
\ No newline at end of file
product/Presentation/Presenters/AddBillPaymentPresenter.cs
@@ -16,7 +16,7 @@ namespace momoney.presentation.presenters
             this.pump = pump;
         }
 
-        public override void present()
+        protected override void present()
         {
             view.attach_to(this);
             pump
product/Presentation/Presenters/AddCompanyPresenter.cs
@@ -15,9 +15,8 @@ namespace MoMoney.Presentation.Presenters
             this.pump = pump;
         }
 
-        public override void present()
+        protected override void present()
         {
-            view.attach_to(this);
             pump.run<IEnumerable<CompanyDTO>, IGetAllCompanysQuery>(view);
         }
 
product/Presentation/Presenters/AddCompanyPresenterSpecs.cs
@@ -10,32 +10,25 @@ namespace MoMoney.Presentation.Presenters
     public abstract class behaves_like_the_add_company_presenter : concerns_for<AddCompanyPresenter>
     {
         context c = () =>
-                        {
-                            view = the_dependency<IAddCompanyView>();
-                            pump = the_dependency<ICommandPump>();
-                        };
+                    {
+                        view = the_dependency<IAddCompanyView>();
+                        pump = the_dependency<ICommandPump>();
+                    };
 
         static protected IAddCompanyView view;
         static protected ICommandPump pump;
     }
 
-    public class when_the_user_is_about_to_add_an_expense : behaves_like_the_add_company_presenter
-    {
-        it should_display_the_correct_screen = () => view.was_told_to(x => x.attach_to(sut));
-
-        because b = () => sut.present();
-    }
-
     [Concern(typeof (AddCompanyPresenter))]
     public class when_registering_a_new_company : behaves_like_the_add_company_presenter
     {
         context c = () =>
-                        {
-                            dto = new RegisterNewCompany {company_name = "Microsoft"};
-                            when_the(pump)
-                                .is_told_to(x => x.run<IRegisterNewCompanyCommand, RegisterNewCompany>(dto))
-                                .it_will_return(pump);
-                        };
+                    {
+                        dto = new RegisterNewCompany {company_name = "Microsoft"};
+                        when_the(pump)
+                            .is_told_to(x => x.run<IRegisterNewCompanyCommand, RegisterNewCompany>(dto))
+                            .it_will_return(pump);
+                    };
 
         because b = () => sut.submit(dto);
 
product/Presentation/Presenters/AddNewIncomePresenter.cs
@@ -15,9 +15,8 @@ namespace MoMoney.Presentation.Presenters
             this.pump = pump;
         }
 
-        public override void present()
+        protected override void present()
         {
-            view.attach_to(this);
             pump.run<IEnumerable<CompanyDTO>, IGetAllCompanysQuery>(view);
             pump.run<IEnumerable<IncomeInformationDTO>, IGetAllIncomeQuery>(view);
         }
product/Presentation/Presenters/AddNewIncomePresenterSpecs.cs
@@ -43,13 +43,14 @@ namespace momoney.presentation.presenters
         it should_display_a_list_of_all_the_registered_company_to_select =
             () => pump.was_told_to(x => x.run<IEnumerable<CompanyDTO>, IGetAllCompanysQuery>(view));
 
-        it should_bind_a_presenter_to_the_screen = () => view.was_told_to(x => x.attach_to(sut));
-
         it should_display_the_income_already_added =
             () => pump.was_told_to(x => x.run<IEnumerable<IncomeInformationDTO>, IGetAllIncomeQuery>(view));
 
-        context c = () => { };
+        context c = () => {
+                              shell = an<IShell>();
+        };
 
-        because b = () => sut.present();
+        because b = () => sut.present(shell);
+        static IShell shell;
     }
 }
\ No newline at end of file
product/Presentation/Presenters/ApplicationMenuPresenter.cs
@@ -2,24 +2,20 @@ using System.Windows.Forms;
 using gorilla.commons.utility;
 using MoMoney.Presentation.Core;
 using MoMoney.Presentation.Model.Menu;
-using momoney.presentation.views;
+using MoMoney.Presentation.Views;
 
 namespace momoney.presentation.presenters
 {
-    public interface IApplicationMenuPresenter : IPresenter {}
-
-    public class ApplicationMenuPresenter : IApplicationMenuPresenter
+    public class ApplicationMenuPresenter : IPresenter
     {
-        readonly ISubMenuRegistry registry;
-        readonly IRegionManager shell;
+        ISubMenuRegistry registry;
 
-        public ApplicationMenuPresenter(ISubMenuRegistry registry, IRegionManager shell)
+        public ApplicationMenuPresenter(ISubMenuRegistry registry)
         {
             this.registry = registry;
-            this.shell = shell;
         }
 
-        public void present()
+        public void present(IShell shell)
         {
             shell.region<MenuStrip>(x => registry.all().each(y => y.add_to(x)));
         }
product/Presentation/Presenters/ApplicationShellPresenter.cs
@@ -6,16 +6,15 @@ using MoMoney.Service.Infrastructure.Eventing;
 
 namespace momoney.presentation.presenters
 {
-    public interface IApplicationShellPresenter : IPresenter, IEventSubscriber<ClosingProjectEvent>
+    public class ApplicationShellPresenter : IPresenter, IEventSubscriber<ClosingProjectEvent>
     {
-        void shut_down();
-    }
+         IShell shell;
+         IEventAggregator broker;
+         IExitCommand command;
 
-    public class ApplicationShellPresenter : IApplicationShellPresenter
-    {
-        readonly IShell shell;
-        readonly IEventAggregator broker;
-        readonly IExitCommand command;
+        protected ApplicationShellPresenter()
+        {
+        }
 
         public ApplicationShellPresenter(IEventAggregator broker, IShell shell, IExitCommand command)
         {
@@ -24,18 +23,17 @@ namespace momoney.presentation.presenters
             this.shell = shell;
         }
 
-        public void present()
+        public virtual void present(IShell shell1)
         {
             broker.subscribe(this);
-            shell.attach_to(this);
         }
 
-        public void notify(ClosingProjectEvent message)
+        public virtual void notify(ClosingProjectEvent message)
         {
             shell.close_all_windows();
         }
 
-        public void shut_down()
+        public virtual void shut_down()
         {
             command.run();
         }
product/Presentation/Presenters/CheckForUpdatesPresenter.cs
@@ -4,19 +4,12 @@ using Gorilla.Commons.Utility;
 using MoMoney.Presentation.Core;
 using MoMoney.Presentation.Presenters;
 using momoney.presentation.views;
+using MoMoney.Presentation.Views;
 using momoney.service.infrastructure.updating;
 
 namespace momoney.presentation.presenters
 {
-    public interface ICheckForUpdatesPresenter : IPresenter, Callback<Percent>
-    {
-        void begin_update();
-        void cancel_update();
-        void restart();
-        void do_not_update();
-    }
-
-    public class CheckForUpdatesPresenter : ICheckForUpdatesPresenter
+    public class CheckForUpdatesPresenter : IPresenter, Callback<Percent>
     {
         readonly ICheckForUpdatesView view;
         readonly ICommandPump pump;
@@ -27,10 +20,9 @@ namespace momoney.presentation.presenters
             this.view = view;
         }
 
-        public void present()
+        public void present(IShell shell)
         {
             pump.run<ApplicationVersion, IWhatIsTheAvailableVersion>(view);
-            view.attach_to(this);
             view.display();
         }
 
product/Presentation/Presenters/CheckForUpdatesPresenterSpecs.cs
@@ -4,13 +4,13 @@ using gorilla.commons.utility;
 using Gorilla.Commons.Utility;
 using MoMoney.Presentation.Presenters;
 using momoney.presentation.views;
+using MoMoney.Presentation.Views;
 using momoney.service.infrastructure.updating;
 
 namespace momoney.presentation.presenters
 {
     [Concern(typeof (CheckForUpdatesPresenter))]
-    public abstract class behaves_like_check_for_updates_presenter :
-        concerns_for<ICheckForUpdatesPresenter, CheckForUpdatesPresenter>
+    public abstract class behaves_like_check_for_updates_presenter : concerns_for< CheckForUpdatesPresenter>
     {
         context c = () =>
         {
@@ -24,15 +24,18 @@ namespace momoney.presentation.presenters
 
     public class when_attempting_to_check_for_updates : behaves_like_check_for_updates_presenter
     {
-        it should_tell_the_view_to_attach_itself_to_the_presenter = () => view.was_told_to(x => x.attach_to(sut));
-
         it should_tell_the_view_to_display_the_information_on_the_current_version_of_the_application =
             () => view.was_told_to(x => x.display());
 
         it should_go_and_find_out_what_the_latest_version_is =
             () => pump.was_told_to(x => x.run<ApplicationVersion, IWhatIsTheAvailableVersion>(view));
 
-        because b = () => sut.present();
+        context c = () =>
+                    {
+                        shell = an<IShell>();
+                    };
+        because b = () => sut.present(shell);
+        static IShell shell;
     }
 
     public class when_initiating_an_update_and_one_is_available : behaves_like_check_for_updates_presenter
product/Presentation/Presenters/GettingStartedPresenter.cs
@@ -8,10 +8,5 @@ namespace momoney.presentation.presenters
         public GettingStartedPresenter(IGettingStartedView view) : base(view)
         {
         }
-
-        public override void present()
-        {
-            view.attach_to(this);
-        }
     }
 }
\ No newline at end of file
product/Presentation/Presenters/GettingStartedPresenterSpecs.cs
@@ -1,30 +1,33 @@
 using developwithpassion.bdd.contexts;
 using Gorilla.Commons.Testing;
 using momoney.presentation.views;
-using MoMoney.Service.Infrastructure.Eventing;
+using MoMoney.Presentation.Views;
 
 namespace momoney.presentation.presenters
 {
     public class GettingStartedPresenterSpecs
     {
-        public class behaves_like_the_getting_started_presenter :
-            concerns_for< GettingStartedPresenter>
+        public class behaves_like_the_getting_started_presenter : concerns_for<GettingStartedPresenter>
         {
             context c = () =>
-            {
-                view = the_dependency<IGettingStartedView>();
-                broker = the_dependency<IEventAggregator>();
-            };
+                        {
+                            view = the_dependency<IGettingStartedView>();
+                        };
 
-            static protected IEventAggregator broker;
             static protected IGettingStartedView view;
         }
 
         public class when_a_new_project_is_opened : behaves_like_the_getting_started_presenter
         {
-            it should_display_the_getting_started_screen = () => view.was_told_to(x => x.attach_to(sut));
+            it should_display_the_getting_started_screen = () => shell.was_told_to(x => x.add(view));
 
-            because b = () => sut.present();
+            context c = () =>
+                        {
+                            shell = an<IShell>();
+                        };
+
+            because b = () => sut.present(shell);
+            static IShell shell;
         }
     }
 }
\ No newline at end of file
product/Presentation/Presenters/LogFilePresenter.cs
@@ -6,14 +6,14 @@ namespace momoney.presentation.presenters
 {
     public class LogFilePresenter : ContentPresenter<ILogFileView>
     {
-        readonly ILogFileTasks tasks;
+        ILogFileTasks tasks;
 
         public LogFilePresenter(ILogFileView view, ILogFileTasks tasks) : base(view)
         {
             this.tasks = tasks;
         }
 
-        public override void present()
+        protected override void present()
         {
             view.display(tasks.get_the_path_to_the_log_file());
             view.run(tasks.get_the_contents_of_the_log_file());
product/Presentation/Presenters/LogFileViewPresenterSpecs.cs
@@ -1,6 +1,7 @@
 using developwithpassion.bdd.contexts;
 using Gorilla.Commons.Testing;
 using momoney.presentation.views;
+using MoMoney.Presentation.Views;
 using momoney.service.infrastructure.logging;
 
 namespace momoney.presentation.presenters
@@ -23,15 +24,17 @@ namespace momoney.presentation.presenters
 
         context c = () =>
         {
+            shell = an<IShell>();
             log_file_path = "log.txt";
             log_file_contents = "hello_jello";
             tasks.is_told_to(x => x.get_the_path_to_the_log_file()).it_will_return(log_file_path);
             tasks.is_told_to(x => x.get_the_contents_of_the_log_file()).it_will_return(log_file_contents);
         };
 
-        because b = () => sut.present();
+        because b = () => sut.present(shell);
 
         static string log_file_contents;
         static string log_file_path;
+        static IShell shell;
     }
 }
\ No newline at end of file
product/Presentation/Presenters/MainMenuPresenter.cs
@@ -15,7 +15,7 @@ namespace MoMoney.Presentation.Presenters
             this.command = command;
         }
 
-        public override void present()
+        protected override void present()
         {
             all_factories().each(x => view.add(x));
         }
product/Presentation/Presenters/NavigationPresenter.cs
@@ -13,7 +13,7 @@ namespace momoney.presentation.presenters
             this.tree_view_visitor = tree_view_visitor;
         }
 
-        public override void present()
+        protected override void present()
         {
             view.accept(tree_view_visitor);
         }
product/Presentation/Presenters/NavigationPresenterSpecs.cs
@@ -2,6 +2,7 @@ using developwithpassion.bdd.contexts;
 using Gorilla.Commons.Testing;
 using MoMoney.Presentation.Model.Navigation;
 using momoney.presentation.views;
+using MoMoney.Presentation.Views;
 
 namespace momoney.presentation.presenters
 {
@@ -12,13 +13,15 @@ namespace momoney.presentation.presenters
 
         context c = () =>
         {
+            shell = an<IShell>();
             view = the_dependency<INavigationView>();
             tree_view_visitor = the_dependency<INavigationTreeVisitor>();
         };
 
-        because b = () => sut.present();
+        because b = () => sut.present(shell);
 
         static INavigationView view;
         static INavigationTreeVisitor tree_view_visitor;
+        static IShell shell;
     }
 }
\ No newline at end of file
product/Presentation/Presenters/ReportPresenter.cs
@@ -17,7 +17,7 @@ namespace MoMoney.Presentation.Presenters
             this.registry = registry;
         }
 
-        public override void present()
+        protected override void present()
         {
             var report = registry.get_a<Report>();
             report.run(registry.get_a<Query>().fetch());
product/Presentation/Presenters/RunPresenterCommand.cs
@@ -1,22 +1,19 @@
 using MoMoney.Presentation.Core;
-using MoMoney.Service.Infrastructure.Threading;
 
 namespace MoMoney.Presentation.Presenters
 {
     public class RunPresenterCommand : IRunPresenterCommand
     {
         readonly IApplicationController application_controller;
-        readonly CommandProcessor processor;
 
-        public RunPresenterCommand(IApplicationController application_controller, CommandProcessor processor)
+        public RunPresenterCommand(IApplicationController application_controller)
         {
             this.application_controller = application_controller;
-            this.processor = processor;
         }
 
         public void run<Presenter>() where Presenter : IPresenter
         {
-            processor.add(() => application_controller.run<Presenter>());
+            application_controller.run<Presenter>();
         }
     }
 }
\ No newline at end of file
product/Presentation/Presenters/ToolBarPresenter.cs
@@ -6,18 +6,15 @@ using MoMoney.Presentation.Model.Menu;
 using momoney.presentation.model.menu.file;
 using MoMoney.Presentation.Model.Projects;
 using momoney.presentation.views;
+using MoMoney.Presentation.Views;
 using MoMoney.Presentation.Winforms.Resources;
 
 namespace momoney.presentation.presenters
 {
-    public interface IToolbarPresenter : IPresenter
+    public class ToolBarPresenter : IPresenter
     {
-    }
-
-    public class ToolBarPresenter : IToolbarPresenter
-    {
-        readonly IRegionManager shell;
-        readonly IProjectController project;
+        IRegionManager shell;
+        IProjectController project;
 
         public ToolBarPresenter(IRegionManager shell, IProjectController project)
         {
@@ -25,7 +22,7 @@ namespace momoney.presentation.presenters
             this.project = project;
         }
 
-        public void present()
+        public void present(IShell shell1)
         {
             shell.region<ToolStrip>(x => buttons().each(y => y.add_to(x)));
         }
product/Presentation/Presenters/UnhandledErrorPresenter.cs
@@ -2,17 +2,12 @@ using MoMoney.Presentation;
 using MoMoney.Presentation.Core;
 using momoney.presentation.model.eventing;
 using momoney.presentation.views;
+using MoMoney.Presentation.Views;
 using MoMoney.Service.Infrastructure.Eventing;
 
 namespace momoney.presentation.presenters
 {
-    public interface IUnhandledErrorPresenter : IModule, IPresenter,
-                                                IEventSubscriber<UnhandledErrorOccurred>
-    {
-        void restart_application();
-    }
-
-    public class UnhandledErrorPresenter : IUnhandledErrorPresenter
+    public class UnhandledErrorPresenter : IModule, IPresenter, IEventSubscriber<UnhandledErrorOccurred>
     {
         readonly IUnhandledErrorView view;
         readonly IEventAggregator broker;
@@ -25,10 +20,8 @@ namespace momoney.presentation.presenters
             this.broker = broker;
         }
 
-        public void present()
+        public void present(IShell shell)
         {
-            view.attach_to(this);
-            broker.subscribe_to(this);
         }
 
         public void notify(UnhandledErrorOccurred message)
@@ -43,7 +36,7 @@ namespace momoney.presentation.presenters
 
         public void run()
         {
-            present();
+            broker.subscribe_to(this);
         }
     }
 }
\ No newline at end of file
product/Presentation/Presenters/UnhandledErrorPresenterSpecs.cs
@@ -7,14 +7,8 @@ using MoMoney.Service.Infrastructure.Eventing;
 
 namespace momoney.presentation.presenters
 {
-    public class behaves_like_unhandled_error_presenter :
-        concerns_for<IUnhandledErrorPresenter, UnhandledErrorPresenter>
+    public class behaves_like_unhandled_error_presenter : concerns_for<UnhandledErrorPresenter>
     {
-        //public override IUnhandledErrorPresenter create_sut()
-        //{
-        //    return new UnhandledErrorPresenter(view, broker);
-        //}
-
         context c = () =>
         {
             view = the_dependency<IUnhandledErrorView>();
product/Presentation/Presenters/ViewAllBillsPresenter.cs
@@ -16,9 +16,8 @@ namespace momoney.presentation.presenters
             this.pump = pump;
         }
 
-        public override void present()
+        protected override void present()
         {
-            view.attach_to(this);
             pump.run<IEnumerable<BillInformationDTO>, IGetAllBillsQuery>(view);
         }
     }
product/Presentation/Presenters/ViewIncomeHistoryPresenter.cs
@@ -15,9 +15,8 @@ namespace MoMoney.Presentation.Presenters
             this.pump = pump;
         }
 
-        public override void present()
+        protected override void present()
         {
-            view.attach_to(this);
             pump.run<IEnumerable<IncomeInformationDTO>, IGetAllIncomeQuery>(view);
         }
     }
product/Presentation/Views/ICheckForUpdatesView.cs
@@ -5,7 +5,7 @@ using momoney.service.infrastructure.updating;
 
 namespace momoney.presentation.views
 {
-    public interface ICheckForUpdatesView : IView<ICheckForUpdatesPresenter>, Callback<ApplicationVersion>
+    public interface ICheckForUpdatesView : IView<CheckForUpdatesPresenter>, Callback<ApplicationVersion>
     {
         void display();
         void downloaded(Percent percentage_complete);
product/Presentation/Views/IRegionManager.cs
@@ -5,6 +5,6 @@ namespace momoney.presentation.views
 {
     public interface IRegionManager
     {
-        void region<T>(Action<T> action) where T : IComponent;
+        void region<Control>(Action<Control> action) where Control : IComponent;
     }
 }
\ No newline at end of file
product/Presentation/Views/IShell.cs
@@ -8,7 +8,7 @@ namespace MoMoney.Presentation.Views
     public interface IShell : IWin32Window, ISynchronizeInvoke, IContainerControl, IBindableComponent, IDropTarget,
                               IRegionManager
     {
-        void attach_to(IApplicationShellPresenter presenter);
+        void attach_to(ApplicationShellPresenter presenter);
         void add(IDockedContentView view);
         void close_the_active_window();
         void close_all_windows();
product/Presentation/Views/IUnhandledErrorView.cs
@@ -3,7 +3,7 @@ using momoney.presentation.presenters;
 
 namespace momoney.presentation.views
 {
-    public interface IUnhandledErrorView : IView<IUnhandledErrorPresenter>
+    public interface IUnhandledErrorView : IView<UnhandledErrorPresenter>
     {
         void display(Exception exception);
     }
product/Presentation/Views/IView.cs
@@ -9,8 +9,8 @@ namespace momoney.presentation.views
     {
     }
 
-    public interface IView<TPresenter> : IView where TPresenter : IPresenter
+    public interface IView<Presenter> : IView where Presenter : IPresenter
     {
-        void attach_to(TPresenter presenter);
+        void attach_to(Presenter presenter);
     }
 }
\ No newline at end of file
product/Presentation/Winforms/Views/ApplicationShell.cs
@@ -41,7 +41,7 @@ namespace MoMoney.Presentation.Winforms.Views
             try_to_reduce_flickering();
         }
 
-        public void attach_to(IApplicationShellPresenter presenter)
+        public void attach_to(ApplicationShellPresenter presenter)
         {
             closed_action = x => presenter.shut_down();
         }
product/Presentation/Winforms/Views/ApplicationShellSpecs.cs
@@ -7,20 +7,20 @@ using MoMoney.Presentation.Winforms.Helpers;
 
 namespace MoMoney.Presentation.Winforms.Views
 {
-    public class behaves_like_application_shell : concerns_for<IShell, ApplicationShell>
+    public class concern : concerns_for<IShell, ApplicationShell>
     {
     }
 
-    public class when_the_application_shell_is_closed : behaves_like_application_shell
+    public class when_the_application_shell_is_closed : concern
     {
         it should_execute_the_close_command = () => presenter.was_told_to(x => x.shut_down());
 
-        context c = () => { presenter = an<IApplicationShellPresenter>(); };
+        context c = () => { presenter = an<ApplicationShellPresenter>(); };
 
         after_the_sut_has_been_created a = () => { sut.attach_to(presenter); };
 
         because b = () => EventTrigger.trigger_event<Events.FormEvents>(x => x.OnClosed(new EventArgs()), sut);
 
-        static IApplicationShellPresenter presenter;
+        static ApplicationShellPresenter presenter;
     }
 }
\ No newline at end of file
product/Presentation/Winforms/Views/CheckForUpdatesView.cs
@@ -35,7 +35,7 @@ namespace MoMoney.Presentation.Winforms.Views
             ux_cancel_button.Click += (o, e) => cancel_button(e);
         }
 
-        public void attach_to(ICheckForUpdatesPresenter presenter)
+        public void attach_to(CheckForUpdatesPresenter presenter)
         {
             update_button = x =>
             {
product/Presentation/Winforms/Views/UnhandledErrorView.cs
@@ -27,7 +27,7 @@ namespace MoMoney.Presentation.Winforms.Views
             this.window = window;
         }
 
-        public void attach_to(IUnhandledErrorPresenter presenter)
+        public void attach_to(UnhandledErrorPresenter presenter)
         {
             close_action = x => Close();
             restart_action = x => presenter.restart_application();
product/Presentation/Presentation.csproj
@@ -104,6 +104,7 @@
   </ItemGroup>
   <ItemGroup>
     <Compile Include="core\CachedPresenterFactory.cs" />
+    <Compile Include="core\CachingViewFactory.cs" />
     <Compile Include="model\eventing\FinishedRunningCommand.cs" />
     <Compile Include="model\eventing\StartedRunningCommand.cs" />
     <Compile Include="model\navigation\INavigationTreeVisitor.cs" />