Commit e8654c4

mokhan <mokhan@ce5e1baf-6525-42e4-a1b2-857ea38da20a>
2009-04-28 20:25:48
registered unit of work interceptors around new commands and queries.
git-svn-id: https://svn.xp-dev.com/svn/mokhan-mo.money@194 ce5e1baf-6525-42e4-a1b2-857ea38da20a
1 parent b32d190
Changed files (10)
trunk
product
Gorilla.Commons.Infrastructure
MoMoney.DTO
MoMoney.Presentation
MoMoney.Service
MyMoney
trunk/product/Gorilla.Commons.Infrastructure/CommandFactory.cs
@@ -1,3 +1,4 @@
+using Gorilla.Commons.Infrastructure.Threading;
 using Gorilla.Commons.Utility.Core;
 
 namespace Gorilla.Commons.Infrastructure
@@ -9,9 +10,16 @@ namespace Gorilla.Commons.Infrastructure
 
     public class CommandFactory : ICommandFactory
     {
+        readonly ISynchronizationContextFactory factory;
+
+        public CommandFactory(ISynchronizationContextFactory factory)
+        {
+            this.factory = factory;
+        }
+
         public ICommand create_for<T>(ICallback<T> item, IQuery<T> query)
         {
-            return new RunQueryCommand<T>(item, new ProcessQueryCommand<T>(query));
+            return new RunQueryCommand<T>(item, new ProcessQueryCommand<T>(query, factory));
         }
     }
 }
\ No newline at end of file
trunk/product/Gorilla.Commons.Infrastructure/ProcessQueryCommand.cs
@@ -1,3 +1,5 @@
+using System;
+using Gorilla.Commons.Infrastructure.Threading;
 using Gorilla.Commons.Utility.Core;
 
 namespace Gorilla.Commons.Infrastructure
@@ -9,15 +11,18 @@ namespace Gorilla.Commons.Infrastructure
     public class ProcessQueryCommand<T> : IProcessQueryCommand<T>
     {
         readonly IQuery<T> query;
+        readonly ISynchronizationContextFactory factory;
 
-        public ProcessQueryCommand(IQuery<T> query)
+        public ProcessQueryCommand(IQuery<T> query, ISynchronizationContextFactory factory)
         {
             this.query = query;
+            this.factory = factory;
         }
 
         public void run(ICallback<T> callback)
         {
-            callback.run(query.fetch());
+            var dto = query.fetch();
+            factory.create().run(new ActionCommand((Action) (()=> callback.run(dto))));
         }
     }
 }
\ No newline at end of file
trunk/product/MoMoney.DTO/CompanyDTO.cs
@@ -11,5 +11,10 @@ namespace MoMoney.DTO
 
         [DataMember]
         public string name { get; set; }
+
+        public override string ToString()
+        {
+            return name;
+        }
     }
 }
\ No newline at end of file
trunk/product/MoMoney.Presentation/Presenters/AddCompanyPresenterSpecs.cs
@@ -17,8 +17,8 @@ namespace MoMoney.Presentation.Presenters
                             pump = the_dependency<ICommandPump>();
                         };
 
-        protected static IAddCompanyView view;
-        protected static ICommandPump pump;
+        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
trunk/product/MoMoney.Presentation/Views/Billing/AddBillPaymentView.cs
@@ -31,7 +31,6 @@ namespace MoMoney.Presentation.Views.billing
         public void run(IEnumerable<CompanyDTO> companys)
         {
             companies_list.bind_to(companys);
-            //ux_company_names.bind_to(companys);
         }
 
         public void run(IEnumerable<BillInformationDTO> bills)
trunk/product/MoMoney.Presentation/Views/Income/AddNewIncomeView.cs
@@ -1,6 +1,5 @@
 using System;
 using System.Collections.Generic;
-using System.Windows.Forms;
 using Gorilla.Commons.Utility.Extensions;
 using Gorilla.Commons.Windows.Forms;
 using Gorilla.Commons.Windows.Forms.Helpers;
@@ -33,7 +32,6 @@ namespace MoMoney.Presentation.Views.income
         public void run(IEnumerable<CompanyDTO> companies)
         {
             companies_list.bind_to(companies);
-            //ux_companys.bind_to(companies);
         }
 
         public void run(IEnumerable<IncomeInformationDTO> incomes)
trunk/product/MoMoney.Service/MoMoney.Service.csproj
@@ -122,6 +122,7 @@
   </ItemGroup>
   <ItemGroup>
     <Folder Include="Domain\" />
+    <Folder Include="Infrastructure\Core\" />
     <Folder Include="Properties\" />
   </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
trunk/product/MyMoney/boot/container/registration/proxy_configuration/ServiceLayerConfiguration.cs
@@ -0,0 +1,15 @@
+using Gorilla.Commons.Infrastructure;
+using Gorilla.Commons.Infrastructure.Castle.DynamicProxy;
+using Gorilla.Commons.Infrastructure.Castle.DynamicProxy.Interceptors;
+using Gorilla.Commons.Utility.Core;
+
+namespace MoMoney.boot.container.registration.proxy_configuration
+{
+    internal class ServiceLayerConfiguration<T> : IConfiguration<IProxyBuilder<T>>
+    {
+        public void configure(IProxyBuilder<T> item)
+        {
+            item.add_interceptor(Lazy.load<IUnitOfWorkInterceptor>()).intercept_all();
+        }
+    }
+}
\ No newline at end of file
trunk/product/MyMoney/boot/container/registration/wire_up_the_services_in_to_the.cs
@@ -1,7 +1,6 @@
 using Gorilla.Commons.Infrastructure;
-using Gorilla.Commons.Infrastructure.Castle.DynamicProxy;
-using Gorilla.Commons.Infrastructure.Castle.DynamicProxy.Interceptors;
 using Gorilla.Commons.Utility.Core;
+using MoMoney.boot.container.registration.proxy_configuration;
 using MoMoney.Domain.accounting.billing;
 using MoMoney.Domain.repositories;
 using MoMoney.Service.Application;
@@ -32,22 +31,23 @@ namespace MoMoney.boot.container.registration
                 () => new GetAllCompanysQuery(Lazy.load<ICompanyRepository>()));
             registry.proxy<IGetAllBillsQuery, ServiceLayerConfiguration<IGetAllBillsQuery>>(
                 () => new GetAllBillsQuery(Lazy.load<IBillRepository>()));
+            registry.proxy<IGetAllIncomeQuery, ServiceLayerConfiguration<IGetAllIncomeQuery>>(
+                () => new GetAllIncomeQuery(Lazy.load<IIncomeRepository>()));
         }
 
         void wire_up_the_commands()
         {
             registry.proxy<IRegisterNewCompanyCommand, ServiceLayerConfiguration<IRegisterNewCompanyCommand>>(
-                () => new RegisterNewCompanyCommand(Lazy.load<ICompanyFactory>(),Lazy.load<INotification>(),Lazy.load<ICompanyRepository>()));
+                () =>
+                new RegisterNewCompanyCommand(Lazy.load<ICompanyFactory>(), Lazy.load<INotification>(),
+                                              Lazy.load<ICompanyRepository>()));
             registry.proxy<ISaveNewBillCommand, ServiceLayerConfiguration<ISaveNewBillCommand>>(
                 () => new SaveNewBillCommand(Lazy.load<ICompanyRepository>(), Lazy.load<ICustomerTasks>()));
-        }
-    }
 
-    internal class ServiceLayerConfiguration<T> : IConfiguration<IProxyBuilder<T>>
-    {
-        public void configure(IProxyBuilder<T> item)
-        {
-            item.add_interceptor(Lazy.load<IUnitOfWorkInterceptor>()).intercept_all();
+            registry.proxy<IAddNewIncomeCommand, ServiceLayerConfiguration<IAddNewIncomeCommand>>(
+                () =>
+                new AddNewIncomeCommand(Lazy.load<ICustomerTasks>(), Lazy.load<INotification>(),
+                                        Lazy.load<IIncomeRepository>(), Lazy.load<ICompanyRepository>()));
         }
     }
 }
\ No newline at end of file
trunk/product/MyMoney/MyMoney.csproj
@@ -167,6 +167,7 @@
     <Compile Include="boot\container\registration\auto_wire_components_in_to_the.cs" />
     <Compile Include="boot\container\registration\auto_wire_components_in_to_the_specs.cs" />
     <Compile Include="boot\container\registration\proxy_configuration\NoConfiguration.cs" />
+    <Compile Include="boot\container\registration\proxy_configuration\ServiceLayerConfiguration.cs" />
     <Compile Include="boot\container\registration\proxy_configuration\SynchronizedConfiguration.cs" />
     <Compile Include="boot\container\registration\wire_up_the_infrastructure_in_to_the.cs" />
     <Compile Include="boot\container\tear_down_the_container.cs" />