Commit 00a8624

mokhan <mokhan@ce5e1baf-6525-42e4-a1b2-857ea38da20a>
2009-03-20 01:04:30
refactored where the splash screen is wired up and how its torn down.
git-svn-id: https://svn.xp-dev.com/svn/mokhan-mo.money@84 ce5e1baf-6525-42e4-a1b2-857ea38da20a
1 parent 930373e
Changed files (8)
trunk/product/MyMoney/Infrastructure/Extensions/threading_extensions.cs
@@ -7,9 +7,7 @@ namespace MoMoney.Infrastructure.Extensions
     {
         public static IBackgroundThread on_a_background_thread(this IDisposableCommand command)
         {
-            var background_thread = new BackgroundThread(command);
-            background_thread.run();
-            return background_thread;
+            return new BackgroundThread(command);
         }
     }
 }
\ No newline at end of file
trunk/product/MyMoney/Presentation/Presenters/Startup/hide_the_splash_screen.cs
@@ -1,5 +1,4 @@
 using System;
-using MoMoney.Infrastructure.Extensions;
 using MoMoney.Infrastructure.Threading;
 using MoMoney.Presentation.Views.Startup;
 
@@ -23,13 +22,11 @@ namespace MoMoney.Presentation.Presenters.Startup
         {
             if (view.current_opacity() == 0)
             {
-                this.log().debug("stop notifying");
                 timer.stop_notifying(presenter);
                 view.close_the_screen();
             }
             else
             {
-                this.log().debug("decrement");
                 view.decrement_the_opacity();
             }
         }
trunk/product/MyMoney/Presentation/Presenters/Startup/SplashScreenPresenter.cs
@@ -1,4 +1,3 @@
-using MoMoney.Infrastructure.Extensions;
 using MoMoney.Infrastructure.Threading;
 using MoMoney.Presentation.Views.Startup;
 using MoMoney.Utility.Core;
@@ -34,7 +33,6 @@ namespace MoMoney.Presentation.Presenters.Startup
 
         public void notify()
         {
-            this.log().debug("update the presenter");
             current_state.update();
         }
     }
trunk/product/MyMoney/Utility/Core/ActionCommand.cs
@@ -0,0 +1,19 @@
+using System;
+
+namespace MoMoney.Utility.Core
+{
+    public class ActionCommand : ICommand
+    {
+        Action action;
+
+        public ActionCommand(Action action)
+        {
+            this.action = action;
+        }
+
+        public void run()
+        {
+            action();
+        }
+    }
+}
\ No newline at end of file
trunk/product/MyMoney/Utility/Extensions/command_extensions.cs
@@ -1,3 +1,4 @@
+using System;
 using System.Collections.Generic;
 using MoMoney.Infrastructure.Threading;
 using MoMoney.Utility.Core;
@@ -16,6 +17,11 @@ namespace MoMoney.Utility.Extensions
             return new chained_command(left, right);
         }
 
+        public static ICommand then(this ICommand left, Action right)
+        {
+            return new chained_command(left, new ActionCommand(right));
+        }
+
         public static ICommand as_command_chain(this IEnumerable<ICommand> commands)
         {
             var processor = new CommandProcessor();
trunk/product/MyMoney/windows.ui/bootstrap.cs
@@ -1,4 +1,6 @@
 using System;
+using MoMoney.Infrastructure.Extensions;
+using MoMoney.Presentation.Presenters.Commands;
 using MoMoney.Utility.Extensions;
 
 namespace MoMoney.windows.ui
@@ -6,11 +8,14 @@ namespace MoMoney.windows.ui
     internal static class bootstrap
     {
         [STAThread]
-        private static void Main()
+        static void Main()
         {
+            var startup_screen = new display_the_splash_screen().on_a_background_thread();
             hookup
                 .the<global_error_handling>()
+                .then(startup_screen)
                 .then<wire_up_the_container>()
+                .then(startup_screen.Dispose)
                 .then<start_the_application>()
                 .run();
         }
trunk/product/MyMoney/windows.ui/wire_up_the_container.cs
@@ -1,6 +1,5 @@
 using MoMoney.Infrastructure.Container.Windsor;
 using MoMoney.Infrastructure.Extensions;
-using MoMoney.Presentation.Presenters.Commands;
 using MoMoney.Utility.Core;
 using MoMoney.Utility.Extensions;
 
@@ -10,16 +9,13 @@ namespace MoMoney.windows.ui
     {
         public void run()
         {
-            using (new display_the_splash_screen().on_a_background_thread())
-            {
-                this.log().debug("initializing container");
-                var registry = new WindsorDependencyRegistry();
-                new wire_up_the_essential_services_into_the(registry)
-                    .then(new wire_up_the_mappers_in_to_the(registry))
-                    .then(new wire_up_the_views_in_to_the(registry))
-                    .then(new wire_up_the_reports_in_to_the(registry))
-                    .run();
-            }
+            this.log().debug("initializing container");
+            var registry = new WindsorDependencyRegistry();
+            new wire_up_the_essential_services_into_the(registry)
+                .then(new wire_up_the_mappers_in_to_the(registry))
+                .then(new wire_up_the_views_in_to_the(registry))
+                .then(new wire_up_the_reports_in_to_the(registry))
+                .run();
         }
     }
 }
\ No newline at end of file
trunk/product/MyMoney/MyMoney.csproj
@@ -537,6 +537,7 @@
     <Compile Include="Presentation\Views\helpers\EventTrigger.cs" />
     <Compile Include="Presentation\Views\helpers\IEventTarget.cs" />
     <Compile Include="Presentation\Views\helpers\EventTriggerSpecs.cs" />
+    <Compile Include="Utility\Core\ActionCommand.cs" />
     <Compile Include="Utility\Core\ChainedConfiguration.cs" />
     <Compile Include="Utility\Core\chained_mapper.cs" />
     <Compile Include="Utility\Core\and_specification.cs" />