Commit 9593eb6

mokhan <mokhan@ce5e1baf-6525-42e4-a1b2-857ea38da20a>
2009-03-26 03:33:27
broke the splash screen trying to figure out this darn threading thing...
git-svn-id: https://svn.xp-dev.com/svn/mokhan-mo.money@110 ce5e1baf-6525-42e4-a1b2-857ea38da20a
1 parent 5f0a309
trunk/product/MyMoney/boot/container/registration/auto_wire_components_in_to_the.cs
@@ -44,7 +44,7 @@ namespace MoMoney.boot.container.registration
             {
                 registrar.transient(type, type);
             }
-            this.log().debug("registered: {0}", type);
+            //this.log().debug("registered: {0}", type);
         }
     }
 }
\ No newline at end of file
trunk/product/MyMoney/boot/container/registration/wire_up_the_views_in_to_the.cs
@@ -1,7 +1,5 @@
-using System.ComponentModel;
 using System.Threading;
 using MoMoney.Infrastructure.Container.Windsor;
-using MoMoney.Infrastructure.interceptors;
 using MoMoney.Infrastructure.proxies;
 using MoMoney.Infrastructure.Threading;
 using MoMoney.Presentation.Views;
@@ -30,10 +28,10 @@ namespace MoMoney.boot.container.registration
         {
             var shell = new ApplicationShell();
             register.singleton<ISynchronizationContext>(new SynchronizedContext(SynchronizationContext.Current));
-            //register.singleton<IShell>(shell);
-            register.proxy(new SynchronizedConfiguration<IShell>(), () => shell);
+            register.singleton<IShell>(shell);
+            //register.proxy(new SynchronizedConfiguration<IShell>(), () => shell);
             register.singleton(shell);
-            //register.proxy(new SynchronizedViewProxyConfiguration<IShell>(), () => new ApplicationShell());
+
             register.transient<IAboutApplicationView, AboutTheApplicationView>();
             register.transient<ISplashScreenView, SplashScreenView>();
             register.transient<INavigationView, NavigationView>();
@@ -53,22 +51,11 @@ namespace MoMoney.boot.container.registration
         }
     }
 
-    internal class SynchronizedViewProxyConfiguration<T> : IConfiguration<IProxyBuilder<T>> where T : ISynchronizeInvoke
-    {
-        public void configure(IProxyBuilder<T> item)
-        {
-            item.add_interceptor<SynchronizedInterceptor<T>>();
-        }
-    }
-
     internal class SynchronizedConfiguration<T> : IConfiguration<IProxyBuilder<T>>
     {
         public void configure(IProxyBuilder<T> item)
         {
-            item
-                .add_interceptor<IThreadSafeInterceptor>(
-                new ThreadSafeInterceptor(Lazy.load<ISynchronizationContextFactory>()))
-                .InterceptAll();
+            item.add_interceptor<ThreadSafeInterceptor>().InterceptAll();
         }
     }
 }
\ No newline at end of file
trunk/product/MyMoney/boot/container/wire_up_the_container.cs
@@ -11,14 +11,23 @@ namespace MoMoney.boot.container
 {
     internal class wire_up_the_container : ICommand
     {
-        public void run()
+        AutofacDependencyRegistryBuilder registry;
+        IComponentExclusionSpecification specification;
+
+        public wire_up_the_container()
+            : this(new AutofacDependencyRegistryBuilder(), new ComponentExclusionSpecification())
+        {
+        }
+
+        public wire_up_the_container(AutofacDependencyRegistryBuilder registry,
+                                     IComponentExclusionSpecification specification)
         {
-            //var container = new WindsorContainerFactory().create();
-            //var registry = new WindsorDependencyRegistry(container);
-            var registry = new AutofacDependencyRegistryBuilder();
-            var specification = new ComponentExclusionSpecification();
-            var configuration = new ComponentRegistrationConfiguration();
+            this.registry = registry;
+            this.specification = specification;
+        }
 
+        public void run()
+        {
             new auto_wire_components_in_to_the(registry, specification)
                 .then(new wire_up_the_essential_services_into_the(registry))
                 .then(new wire_up_the_data_access_components_into_the(registry))
@@ -28,7 +37,6 @@ namespace MoMoney.boot.container
                 .then(new wire_up_the_presentation_modules(registry))
                 .then(new wire_up_the_views_in_to_the(registry))
                 .then(new wire_up_the_reports_in_to_the(registry))
-                //.then(new run_mass_component_registration_in_to_the(container, specification, configuration))
                 .run();
 
             Func<IContainer> func = registry.build;
trunk/product/MyMoney/Infrastructure/Threading/SynchronizedContext.cs
@@ -1,4 +1,3 @@
-using System;
 using System.Threading;
 using MoMoney.Utility.Core;
 
@@ -10,16 +9,12 @@ namespace MoMoney.Infrastructure.Threading
 
         public SynchronizedContext(SynchronizationContext context)
         {
-            if (context != null) this.context = context;
-            else
-            {
-                throw new ArgumentNullException();
-            }
+            this.context = context;
         }
 
         public void run(ICommand item)
         {
-            context.Post(x => item.run(), null);
+            context.Post(x => item.run(), new object());
         }
     }
 }
\ No newline at end of file
trunk/product/MyMoney/Infrastructure/Threading/ThreadSafeInterceptor.cs
@@ -1,4 +1,5 @@
 using Castle.Core.Interceptor;
+using MoMoney.Infrastructure.interceptors;
 using MoMoney.Utility.Core;
 
 namespace MoMoney.Infrastructure.Threading
@@ -11,6 +12,10 @@ namespace MoMoney.Infrastructure.Threading
     {
         readonly ISynchronizationContextFactory factory;
 
+        public ThreadSafeInterceptor() : this(Lazy.load<ISynchronizationContextFactory>())
+        {
+        }
+
         public ThreadSafeInterceptor(ISynchronizationContextFactory factory)
         {
             this.factory = factory;
trunk/product/MyMoney/Presentation/Presenters/Commands/display_the_splash_screen.cs
@@ -20,6 +20,7 @@ namespace MoMoney.Presentation.Presenters.Commands
 
         public void Dispose()
         {
+            presenter().run("Complete");
             presenter().Dispose();
         }
     }
trunk/product/MyMoney/Presentation/Presenters/Startup/SplashScreenPresenter.cs
@@ -41,7 +41,7 @@ namespace MoMoney.Presentation.Presenters.Startup
             current_state.update();
         }
 
-        public void complete(notification_message item)
+        public void run(notification_message item)
         {
             view.notify(item);
         }
trunk/product/MyMoney/Presentation/Presenters/updates/CheckForUpdatesPresenter.cs
@@ -54,7 +54,7 @@ namespace MoMoney.Presentation.Presenters.updates
             view.close();
         }
 
-        public void complete(Percent completed)
+        public void run(Percent completed)
         {
             if (completed.Equals(new Percent(100)))
                 view.update_complete();
trunk/product/MyMoney/Presentation/Presenters/updates/CheckForUpdatesPresenterSpecs.cs
@@ -55,14 +55,14 @@ namespace MoMoney.Presentation.Presenters.updates
     {
         it should_notify_you_of_the_progress_of_the_update = () => view.was_told_to(x => x.downloaded(50));
 
-        because b = () => sut.complete(50);
+        because b = () => sut.run(50);
     }
 
     public class when_an_update_is_completed : behaves_like_check_for_updates_presenter
     {
         it should_notify_the_view_that_the_update_is_complete = () => view.was_told_to(x => x.update_complete());
 
-        because b = () => sut.complete(100);
+        because b = () => sut.run(100);
     }
 
     public class when_an_update_is_cancelled : behaves_like_check_for_updates_presenter
trunk/product/MyMoney/Presentation/Views/core/ApplicationWindow.cs
@@ -58,8 +58,9 @@ namespace MoMoney.Presentation.Views.core
 
         protected void on_ui_thread(Action action)
         {
-            //context.Post(x => action(), new object());
-            operation.Post(x => action(), new object());
+            context.Post(x => action(), new object());
+            //action();
+            //operation.Post(x => action(), new object());
             //if (InvokeRequired)
             //{
             //    BeginInvoke(action);
trunk/product/MyMoney/Presentation/Views/Startup/SplashScreenView.cs
@@ -56,7 +56,6 @@ namespace MoMoney.Presentation.Views.Startup
 
         public void notify(notification_message message)
         {
-            on_ui_thread(() => { this.log().debug(message); });
         }
     }
 }
\ No newline at end of file
trunk/product/MyMoney/Presentation/Views/Startup/SplashScreenView.Designer.cs
@@ -27,13 +27,22 @@ namespace MoMoney.Presentation.Views.Startup {
         /// </summary>
         private void InitializeComponent()
         {
+            this.progress_bar = new System.Windows.Forms.ProgressBar();
             this.SuspendLayout();
             // 
+            // progress_bar
+            // 
+            this.progress_bar.Location = new System.Drawing.Point(8, 225);
+            this.progress_bar.Name = "progress_bar";
+            this.progress_bar.Size = new System.Drawing.Size(272, 26);
+            this.progress_bar.TabIndex = 0;
+            // 
             // SplashScreenView
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.ClientSize = new System.Drawing.Size(282, 255);
+            this.Controls.Add(this.progress_bar);
             this.Name = "SplashScreenView";
             this.ShowIcon = false;
             this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
@@ -44,5 +53,7 @@ namespace MoMoney.Presentation.Views.Startup {
 
         #endregion
 
+        private System.Windows.Forms.ProgressBar progress_bar;
+
     }
 }
\ No newline at end of file
trunk/product/MyMoney/Tasks/infrastructure/UpdateTasks.cs
@@ -48,8 +48,8 @@ namespace MoMoney.Tasks.infrastructure
 
         public void grab_the_latest_version(ICallback<Percent> callback)
         {
-            deployment.UpdateProgressChanged += (o, e) => callback.complete(new Percent(e.BytesCompleted, e.BytesTotal));
-            deployment.UpdateCompleted += (sender, args) => callback.complete(new Percent(100));
+            deployment.UpdateProgressChanged += (o, e) => callback.run(new Percent(e.BytesCompleted, e.BytesTotal));
+            deployment.UpdateCompleted += (sender, args) => callback.run(100);
             deployment.UpdateAsync();
         }
 
trunk/product/MyMoney/Utility/Core/EmptyCallback.cs
@@ -2,11 +2,11 @@ namespace MoMoney.Utility.Core
 {
     public class EmptyCallback<T> : ICallback<T>, ICallback
     {
-        public void complete(T item)
+        public void run(T item)
         {
         }
 
-        public void complete()
+        public void run()
         {
         }
     }
trunk/product/MyMoney/Utility/Core/ICallback.cs
@@ -1,12 +1,10 @@
 namespace MoMoney.Utility.Core
 {
-    public interface ICallback
+    public interface ICallback : ICommand
     {
-        void complete();
     }
 
-    public interface ICallback<T>
+    public interface ICallback<T> : IParameterizedCommand<T>
     {
-        void complete(T item);
     }
 }
\ No newline at end of file