Commit 926459c

mokhan <mokhan@ce5e1baf-6525-42e4-a1b2-857ea38da20a>
2009-03-21 01:16:36
refactoring how items are registered with the container.
git-svn-id: https://svn.xp-dev.com/svn/mokhan-mo.money@91 ce5e1baf-6525-42e4-a1b2-857ea38da20a
1 parent 48b1f8b
trunk/product/MyMoney/boot/container/run_mass_component_registration_in_to_the.cs → trunk/product/MyMoney/boot/container/registration/run_mass_component_registration_in_to_the.cs
File renamed without changes
trunk/product/MyMoney/boot/container/registration/wire_up_the_data_access_components_into_the.cs
@@ -0,0 +1,21 @@
+using MoMoney.DataAccess.db40;
+using MoMoney.Infrastructure.Container.Windsor;
+using MoMoney.Utility.Core;
+
+namespace MoMoney.boot.container.registration
+{
+    internal class wire_up_the_data_access_components_into_the : ICommand
+    {
+        readonly IContainerBuilder register;
+
+        public wire_up_the_data_access_components_into_the(IContainerBuilder registry)
+        {
+            register = registry;
+        }
+
+        public void run()
+        {
+            register.singleton<ISessionContext, SessionContext>();
+        }
+    }
+}
\ No newline at end of file
trunk/product/MyMoney/boot/container/wire_up_the_essential_services_into_the.cs → trunk/product/MyMoney/boot/container/registration/wire_up_the_essential_services_into_the.cs
@@ -19,6 +19,7 @@ namespace MoMoney.boot.container
         {
             resolve.initialize_with(registry);
             registry.singleton<IDependencyRegistry>(registry);
+            registry.singleton<IContainerBuilder>(registry);
             registry.singleton<ILogFactory, Log4NetLogFactory>();
         }
     }
trunk/product/MyMoney/boot/container/wire_up_the_mappers_in_to_the.cs → trunk/product/MyMoney/boot/container/registration/wire_up_the_mappers_in_to_the.cs
@@ -1,7 +1,7 @@
 using MoMoney.Infrastructure.Container.Windsor;
 using MoMoney.Utility.Core;
 
-namespace MoMoney.windows.ui
+namespace MoMoney.boot.container
 {
     internal class wire_up_the_mappers_in_to_the : ICommand
     {
trunk/product/MyMoney/boot/container/wire_up_the_reports_in_to_the.cs → trunk/product/MyMoney/boot/container/registration/wire_up_the_reports_in_to_the.cs
File renamed without changes
trunk/product/MyMoney/boot/container/wire_up_the_views_in_to_the.cs → trunk/product/MyMoney/boot/container/registration/wire_up_the_views_in_to_the.cs
File renamed without changes
trunk/product/MyMoney/boot/container/wire_up_the_container.cs
@@ -1,5 +1,6 @@
 using System;
 using Castle.Windsor;
+using MoMoney.boot.container.registration;
 using MoMoney.Infrastructure.Container.Windsor;
 using MoMoney.Infrastructure.Container.Windsor.configuration;
 using MoMoney.Utility.Core;
@@ -20,6 +21,7 @@ namespace MoMoney.boot.container
             var configuration = new ComponentRegistrationConfiguration();
 
             new wire_up_the_essential_services_into_the(registry)
+                .then(new wire_up_the_data_access_components_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))
trunk/product/MyMoney/DataAccess/db40/DatabaseConfiguration.cs
@@ -1,37 +0,0 @@
-using System;
-using Castle.Core;
-using MoMoney.Presentation.Model.Projects;
-
-namespace MoMoney.DataAccess.db40
-{
-    public interface IDatabaseConfiguration
-    {
-        IFile path_to_the_database();
-        void change_path_to(IFile file);
-    }
-
-    [Singleton]
-    public class DatabaseConfiguration : IDatabaseConfiguration
-    {
-        IFile the_path_to_the_database_file;
-
-        public IFile path_to_the_database()
-        {
-            ensure_that_a_path_is_specified();
-            return the_path_to_the_database_file;
-        }
-
-        public void change_path_to(IFile file)
-        {
-            the_path_to_the_database_file = file;
-        }
-
-        void ensure_that_a_path_is_specified()
-        {
-            if (null == the_path_to_the_database_file)
-            {
-                throw new ArgumentException("A path to the database is not specified.");
-            }
-        }
-    }
-}
\ No newline at end of file
trunk/product/MyMoney/DataAccess/db40/SessionContextSpecs.cs
@@ -13,11 +13,9 @@ namespace MoMoney.DataAccess.db40
         context c = () =>
                         {
                             connection_factory = the_dependency<IConnectionFactory>();
-                            database_configuration = the_dependency<IDatabaseConfiguration>();
                         };
 
         protected static IConnectionFactory connection_factory;
-        protected static IDatabaseConfiguration database_configuration;
     }
 
     public class when_creating_a_new_session_to_a_db40_database : behaves_like_a_session_factory
@@ -30,7 +28,6 @@ namespace MoMoney.DataAccess.db40
                     var the_path_to_the_database_file = an<IFile>();
                     session = an<IObjectContainer>();
 
-                    database_configuration.is_told_to(x => x.path_to_the_database()).it_will_return( the_path_to_the_database_file);
                     connection_factory.is_told_to(x => x.open_connection_to(the_path_to_the_database_file)). it_will_return(session);
                 };
 
trunk/product/MyMoney/MyMoney.csproj
@@ -161,8 +161,8 @@
   </ItemGroup>
   <ItemGroup>
     <Compile Include="boot\container\tear_down_the_container.cs" />
+    <Compile Include="boot\container\registration\wire_up_the_data_access_components_into_the.cs" />
     <Compile Include="DataAccess\db40\ConnectionFactory.cs" />
-    <Compile Include="DataAccess\db40\DatabaseConfiguration.cs" />
     <Compile Include="DataAccess\db40\EmptySession.cs" />
     <Compile Include="DataAccess\db40\ObjectDatabaseGateway.cs" />
     <Compile Include="DataAccess\db40\ObjectDatabaseGatewaySpecs.cs" />
@@ -758,11 +758,11 @@
     <Compile Include="boot\start_the_application.cs" />
     <Compile Include="boot\container\wire_up_the_container.cs" />
     <Compile Include="boot\global_error_handling.cs" />
-    <Compile Include="boot\container\run_mass_component_registration_in_to_the.cs" />
-    <Compile Include="boot\container\wire_up_the_essential_services_into_the.cs" />
-    <Compile Include="boot\container\wire_up_the_mappers_in_to_the.cs" />
-    <Compile Include="boot\container\wire_up_the_reports_in_to_the.cs" />
-    <Compile Include="boot\container\wire_up_the_views_in_to_the.cs" />
+    <Compile Include="boot\container\registration\run_mass_component_registration_in_to_the.cs" />
+    <Compile Include="boot\container\registration\wire_up_the_essential_services_into_the.cs" />
+    <Compile Include="boot\container\registration\wire_up_the_mappers_in_to_the.cs" />
+    <Compile Include="boot\container\registration\wire_up_the_reports_in_to_the.cs" />
+    <Compile Include="boot\container\registration\wire_up_the_views_in_to_the.cs" />
   </ItemGroup>
   <ItemGroup>
     <Folder Include="DataAccess\sqlcompact\" />