Commit f6274c7

mo khan <mo@mokhan.ca>
2010-02-04 04:11:33
tried to register the dialogs as transients but two different references were used when loading the view.
1 parent 5a2bfe2
Changed files (7)
product
client
boot
boot
container
presentation
presentation.winforms
commons
product/client/boot/boot/container/registration/WireUpTheViewsInToThe.cs
@@ -37,14 +37,14 @@ namespace MoMoney.boot.container.registration
             register_singleton<IStatusBarView, StatusBarView>();
             register_singleton<IGettingStartedView, WelcomeScreen>();
             register_singleton<ILogFileView, LogFileView>();
-            register.singleton<ITitleBar, TitleBar>();
-            register.singleton<ITaskTrayMessageView, TaskTrayMessage>();
+            register_singleton<ITitleBar, TitleBar>();
+            register_singleton<ITaskTrayMessageView, TaskTrayMessage>();
 
-            register_singleton<ISelectFileToOpenDialog, SelectFileToOpenDialog>();
-            register_singleton<ISelectFileToSaveToDialog, SelectFileToSaveToDialog>();
-            register_singleton<ISaveChangesView, SaveChangesView>();
-            register_singleton<ICheckForUpdatesView, CheckForUpdatesView>();
-            register_singleton<IUnhandledErrorView, UnhandledErrorView>();
+            register_transient<ISelectFileToOpenDialog, SelectFileToOpenDialog>();
+            register_transient<ISelectFileToSaveToDialog, SelectFileToSaveToDialog>();
+            register_transient<ISaveChangesView, SaveChangesView>();
+            register_transient<ICheckForUpdatesView, CheckForUpdatesView>();
+            register_transient<IUnhandledErrorView, UnhandledErrorView>();
         }
 
         void register_singleton<Interface, View>() where View : Interface, new() where Interface : momoney.presentation.views.View
@@ -53,5 +53,14 @@ namespace MoMoney.boot.container.registration
             register.singleton<Interface>(() => view);
             register.singleton<momoney.presentation.views.View>(() => view);
         }
+
+        void register_transient<Interface, View>() where View : Interface, new() where Interface : momoney.presentation.views.View
+        {
+            var view = new View();
+            register.singleton<Interface>(() => view);
+            register.singleton<momoney.presentation.views.View>(() => view);
+            //register.transient<Interface,View>();
+            //register.transient<momoney.presentation.views.View>(() => Resolve.the<Interface>());
+        }
     }
 }
\ No newline at end of file
product/client/presentation/Core/CachingViewFactory.cs
@@ -1,4 +1,3 @@
-using System;
 using System.Linq;
 using Gorilla.Commons.Infrastructure.Logging;
 using gorilla.commons.utility;
@@ -31,25 +30,6 @@ namespace MoMoney.Presentation.Core
 
             public void attach_to(T presenter) {}
 
-            public IAsyncResult BeginInvoke(Delegate method, object[] args)
-            {
-                return null;
-            }
-
-            public object EndInvoke(IAsyncResult result)
-            {
-                return new object();
-            }
-
-            public object Invoke(Delegate method, object[] args)
-            {
-                return new object();
-            }
-
-            public bool InvokeRequired { get; set; }
-
-            public void Dispose() {}
-
             public override string ToString()
             {
                 return typeof (Null<T>).ToString();
product/client/presentation/Views/View.cs
@@ -1,9 +1,6 @@
-using System;
-
 namespace momoney.presentation.views
 {
-    public interface View //: IDisposable 
-    {}
+    public interface View {}
 
     public interface View<Presenter> : View where Presenter : MoMoney.Presentation.Core.Presenter
     {
product/client/presentation.winforms/views/TaskTrayMessage.cs
@@ -1,4 +1,4 @@
-using System;
+using Gorilla.Commons.Infrastructure.Container;
 using gorilla.commons.utility;
 using momoney.presentation.presenters;
 using momoney.presentation.views;
@@ -7,44 +7,11 @@ namespace MoMoney.Presentation.Winforms.Views
 {
     public class TaskTrayMessage : ITaskTrayMessageView
     {
-        readonly INotificationIconView view;
-
-        public TaskTrayMessage(INotificationIconView view)
-        {
-            this.view = view;
-        }
-
         public void display(string message, params object[] arguments)
         {
-            view.show_popup_message(message.formatted_using(arguments));
+            Resolve.the<INotificationIconView>().show_popup_message(message.formatted_using(arguments));
         }
 
-        public void attach_to(TaskTrayPresenter presenter)
-        {
-        }
-
-        public IAsyncResult BeginInvoke(Delegate method, object[] args)
-        {
-            throw new NotImplementedException();
-        }
-
-        public object EndInvoke(IAsyncResult result)
-        {
-            throw new NotImplementedException();
-        }
-
-        public object Invoke(Delegate method, object[] args)
-        {
-            throw new NotImplementedException();
-        }
-
-        public bool InvokeRequired
-        {
-            get { throw new NotImplementedException(); }
-        }
-
-        public void Dispose()
-        {
-        }
+        public void attach_to(TaskTrayPresenter presenter) {}
     }
 }
\ No newline at end of file
product/client/presentation.winforms/views/TitleBar.cs
@@ -1,5 +1,6 @@
 using System;
 using System.Windows.Forms;
+using Gorilla.Commons.Infrastructure.Container;
 using momoney.presentation.presenters;
 using momoney.presentation.views;
 using MoMoney.Presentation.Views;
@@ -8,12 +9,6 @@ namespace MoMoney.Presentation.Winforms.Views
 {
     public class TitleBar : ITitleBar
     {
-        IRegionManager shell;
-
-        public TitleBar(IRegionManager shell)
-        {
-            this.shell = shell;
-        }
 
         public void attach_to(TitleBarPresenter presenter)
         {
@@ -21,7 +16,7 @@ namespace MoMoney.Presentation.Winforms.Views
 
         public void display(string title)
         {
-            shell.region<Form>(x =>
+            Resolve.the<IRegionManager>().region<Form>(x =>
             {
                 if (x.Text.Contains("-")) x.Text = x.Text.Remove(x.Text.IndexOf("-") - 1);
                 x.Text = x.Text + " - " + title;
@@ -30,7 +25,7 @@ namespace MoMoney.Presentation.Winforms.Views
 
         public void append_asterik()
         {
-            shell.region<Form>(x =>
+            Resolve.the<IRegionManager>().region<Form>(x =>
             {
                 if (x.Text.Contains("*")) return;
                 x.Text = x.Text + "*";
@@ -39,7 +34,7 @@ namespace MoMoney.Presentation.Winforms.Views
 
         public void remove_asterik()
         {
-            shell.region<Form>(x =>
+            Resolve.the<IRegionManager>().region<Form>(x =>
             {
                 x.Text = x.Text.Replace("*", "");
             });
product/commons/infrastructure.thirdparty/autofac/AutofacDependencyRegistryBuilder.cs
@@ -54,6 +54,11 @@ namespace gorilla.commons.infrastructure.thirdparty.Autofac
                 builder.Register(implementation).As(contract).FactoryScoped();
         }
 
+        public void transient<Contract>(Func<Contract> factory_method)
+        {
+            builder.Register(x => factory_method()).As<Contract>().FactoryScoped();
+        }
+
         public void proxy<T>(Configuration<ProxyBuilder<T>> configuration, Func<T> target)
         {
             var proxy_builder = new CastleDynamicProxyBuilder<T>();
product/commons/infrastructure.thirdparty/DependencyRegistration.cs
@@ -13,6 +13,7 @@ namespace gorilla.commons.infrastructure.thirdparty
 
         void transient<Contract, Implementation>() where Implementation : Contract;
         void transient(Type contract, Type implementation);
+        void transient<Contract>(Func<Contract> factory_method);
 
         [Obsolete]
         void proxy<T, Configuration>(Func<T> target) where Configuration : Configuration<ProxyBuilder<T>>, new();