Commit df42876

mokhan <mokhan@ce5e1baf-6525-42e4-a1b2-857ea38da20a>
2009-02-28 16:19:08
changing how the unit of work works.
git-svn-id: https://svn.xp-dev.com/svn/mokhan-mo.money@28 ce5e1baf-6525-42e4-a1b2-857ea38da20a
1 parent ddbf412
trunk/build/project.build
@@ -1,4 +1,4 @@
-<project name="mymoney">	
+<project name="momoney">	
 	<property name="project.name" value="${project::get-name()}" />
 
 	<property name="base.dir" value="${directory::get-parent-directory(project::get-base-directory())}" />
trunk/build/project.install.build
@@ -42,8 +42,8 @@
   </target>
 	
 	<target name="create.installer" depends="load_local_properties,create.installation.dir,create.bootstrap">		
-		<property name="args.new.application" value="-n Application -t ${application.manifest} -fd ${build.compile.dir} -v ${assembly.version} -n mymoney -cf ${certificate.filename} -pwd ${certificate.password} -pub mokhan.ca -tr FullTrust -UseManifestForTrust true -wpf false" />
-		<property name="args.new.deployment" value="-n Deployment -t ${deployment.manifest} -pu ${deployment.url}/${app.output}.application -appm ${application.manifest} -i true -v ${assembly.version} -appc ${deployment.url}\${assembly.version}\${app.output}.manifest -cf ${certificate.filename} -pwd ${certificate.password} -n mymoney -pub mokhan.ca -wpf false" />
+		<property name="args.new.application" value="-n Application -t ${application.manifest} -fd ${build.compile.dir} -v ${assembly.version} -n momoney -cf ${certificate.filename} -pwd ${certificate.password} -pub mokhan.ca -tr FullTrust -UseManifestForTrust true -wpf false" />
+		<property name="args.new.deployment" value="-n Deployment -t ${deployment.manifest} -pu ${deployment.url}/${app.output}.application -appm ${application.manifest} -i true -v ${assembly.version} -appc ${deployment.url}\${assembly.version}\${app.output}.manifest -cf ${certificate.filename} -pwd ${certificate.password} -n momoney -pub mokhan.ca -wpf false" />
 		<property name="args.update.deployment" value="-u ${deployment.manifest} -appm ${application.manifest} -v ${assembly.version}" />	
 		<property name="args.sign.application" value="-s ${application.manifest} -cf ${certificate.filename} -Password ${certificate.password}" />
 		<property name="args.sign.deployment" value="-s ${deployment.manifest} -cf ${certificate.filename} -Password ${certificate.password}" />
trunk/src/MyMoney/DataAccess/db40/connection_factory.cs → trunk/src/MyMoney/DataAccess/db40/ConnectionFactory.cs
@@ -9,7 +9,7 @@ namespace MyMoney.DataAccess.db40
         IObjectContainer open_connection_to(IFile the_path_to_the_database_file);
     }
 
-    public class connection_factory : IConnectionFactory
+    public class ConnectionFactory : IConnectionFactory
     {
         public IObjectContainer open_connection_to(IFile the_path_to_the_database_file)
         {
trunk/src/MyMoney/DataAccess/db40/database_configuration.cs → trunk/src/MyMoney/DataAccess/db40/DatabaseConfiguration.cs
@@ -11,11 +11,11 @@ namespace MyMoney.DataAccess.db40
     }
 
     [Singleton]
-    public class database_configuration : IDatabaseConfiguration
+    public class DatabaseConfiguration : IDatabaseConfiguration
     {
-        file the_path_to_the_database_file;
+        ApplicationFile the_path_to_the_database_file;
 
-        public database_configuration()
+        public DatabaseConfiguration()
         {
             the_path_to_the_database_file = Path.GetTempFileName();
         }
trunk/src/MyMoney/DataAccess/db40/db4o_repository_specs.cs
@@ -9,12 +9,12 @@ using mocking_extensions=MyMoney.Testing.spechelpers.core.mocking_extensions;
 
 namespace MyMoney.DataAccess.db40
 {
-    [Concern(typeof (db4o_repository))]
-    public abstract class behaves_like_a_object_repository : concerns_for<IRepository, db4o_repository>
+    [Concern(typeof (ObjectRepository))]
+    public abstract class behaves_like_a_object_repository : concerns_for<IRepository, ObjectRepository>
     {
         public override IRepository create_sut()
         {
-            return new db4o_repository(factory);
+            return new ObjectRepository(factory);
         }
 
         context c = () => { factory = the_dependency<ISessionFactory>(); };
trunk/src/MyMoney/DataAccess/db40/db4o_repository.cs → trunk/src/MyMoney/DataAccess/db40/ObjectRepository.cs
@@ -6,11 +6,11 @@ using MyMoney.Utility.Extensions;
 
 namespace MyMoney.DataAccess.db40
 {
-    public class db4o_repository : IRepository
+    public class ObjectRepository : IRepository
     {
         readonly ISessionFactory factory;
 
-        public db4o_repository(ISessionFactory factory)
+        public ObjectRepository(ISessionFactory factory)
         {
             this.factory = factory;
         }
trunk/src/MyMoney/Domain/accounting/billing/Bill.cs
@@ -14,7 +14,7 @@ namespace MyMoney.Domain.accounting.billing
         IDate due_date { get; }
     }
 
-    internal class bill : entity<IBill>, IBill
+    internal class bill : Entity<IBill>, IBill
     {
         public bill(ICompany company_to_pay, IMoney the_amount_owed, DateTime due_date)
         {
@@ -36,7 +36,7 @@ namespace MyMoney.Domain.accounting.billing
 
         public void pay(IMoney amount_to_pay)
         {
-            payments.Add(new payment(amount_to_pay));
+            payments.Add(new Payment(amount_to_pay));
         }
 
         private IMoney the_amount_paid()
trunk/src/MyMoney/Domain/accounting/billing/Company.cs
@@ -11,9 +11,9 @@ namespace MyMoney.Domain.accounting.billing
         void pay(IAccountHolder person, IMoney amount, IDate date_of_payment);
     }
 
-    internal class company : entity<ICompany>, ICompany
+    internal class Company : Entity<ICompany>, ICompany
     {
-        public company(string name_of_the_company)
+        public Company(string name_of_the_company)
         {
             name = name_of_the_company;
         }
@@ -27,7 +27,7 @@ namespace MyMoney.Domain.accounting.billing
 
         public void pay(IAccountHolder person, IMoney amount, IDate date_of_payment)
         {
-            person.recieve(new income(date_of_payment, amount, this));
+            person.recieve(new Income(date_of_payment, amount, this));
         }
 
         public override string ToString()
trunk/src/MyMoney/Domain/accounting/billing/company_specs.cs
@@ -8,7 +8,7 @@ using MyMoney.Testing.spechelpers.core;
 
 namespace MyMoney.Domain.accounting.billing
 {
-    [Concern(typeof (company))]
+    [Concern(typeof (Company))]
     public class behaves_like_a_company : concerns_for<ICompany>
     {
         protected string company_name;
@@ -16,7 +16,7 @@ namespace MyMoney.Domain.accounting.billing
         public override ICompany create_sut()
         {
             company_name = "enmax";
-            return new company(company_name);
+            return new Company(company_name);
         }
     }
 
@@ -42,7 +42,7 @@ namespace MyMoney.Domain.accounting.billing
     public class when_a_company_pays_an_employee_or_consultant_for_services : behaves_like_a_company
     {
         it should_pay_the_total_amount_that_is_due =
-            () => person.was_told_to(x => x.recieve(new income(date_of_payment, two_thousand_dollars, sut)));
+            () => person.was_told_to(x => x.recieve(new Income(date_of_payment, two_thousand_dollars, sut)));
 
         context c = () =>
                         {
trunk/src/MyMoney/Domain/accounting/billing/Payment.cs
@@ -7,16 +7,16 @@ namespace MyMoney.Domain.accounting.billing
         IMoney amount_paid { get; }
     }
 
-    internal class payment : entity<IPayment>, IPayment
+    internal class Payment : Entity<IPayment>, IPayment
     {
-        public payment(IMoney amount_paid)
+        public Payment(IMoney amount_paid)
         {
             this.amount_paid = amount_paid;
         }
 
         public IMoney amount_paid { get; private set; }
 
-        public bool Equals(payment obj)
+        public bool Equals(Payment obj)
         {
             if (ReferenceEquals(null, obj)) return false;
             if (ReferenceEquals(this, obj)) return true;
@@ -27,7 +27,7 @@ namespace MyMoney.Domain.accounting.billing
         {
             if (ReferenceEquals(null, obj)) return false;
             if (ReferenceEquals(this, obj)) return true;
-            return Equals(obj as payment);
+            return Equals(obj as Payment);
         }
 
         public override int GetHashCode()
trunk/src/MyMoney/Domain/accounting/financial_growth/income.cs
@@ -10,9 +10,9 @@ namespace MyMoney.Domain.accounting.financial_growth
         ICompany company { get; }
     }
 
-    internal class income : entity<IIncome>, IIncome
+    internal class Income : Entity<IIncome>, IIncome
     {
-        public income(IDate date_of_issue, IMoney amount_tendered, ICompany company)
+        public Income(IDate date_of_issue, IMoney amount_tendered, ICompany company)
         {
             this.company = company;
             this.amount_tendered = amount_tendered;
@@ -23,7 +23,7 @@ namespace MyMoney.Domain.accounting.financial_growth
         public IMoney amount_tendered { get; private set; }
         public IDate date_of_issue { get; private set; }
 
-        public bool Equals(income obj)
+        public bool Equals(Income obj)
         {
             if (ReferenceEquals(null, obj)) return false;
             if (ReferenceEquals(this, obj)) return true;
@@ -35,8 +35,8 @@ namespace MyMoney.Domain.accounting.financial_growth
         {
             if (ReferenceEquals(null, obj)) return false;
             if (ReferenceEquals(this, obj)) return true;
-            if (obj.GetType() != typeof (income)) return false;
-            return Equals((income) obj);
+            if (obj.GetType() != typeof (Income)) return false;
+            return Equals((Income) obj);
         }
 
         public override int GetHashCode()
trunk/src/MyMoney/Domain/accounting/account_holder.cs
@@ -14,7 +14,7 @@ namespace MyMoney.Domain.accounting
         IMoney calculate_income_for(IYear year);
     }
 
-    internal class account_holder : entity<IAccountHolder>, IAccountHolder
+    internal class account_holder : Entity<IAccountHolder>, IAccountHolder
     {
         public account_holder()
         {
trunk/src/MyMoney/Domain/Core/Entity.cs
@@ -8,17 +8,18 @@ namespace MyMoney.Domain.Core
         Guid Id { get; }
     }
 
-    internal abstract class entity<T> : IEntity where T : class, IEntity
+    [Serializable]
+    internal abstract class Entity<T> : IEntity where T : class, IEntity
     {
-        protected entity()
+        protected Entity()
         {
             Id = Guid.NewGuid();
-            UnitOfWork.start_for<T>().register(this as T);
+            UnitOfWork.For<T>().register(this as T);
         }
 
         public Guid Id { get; private set; }
 
-        public bool Equals(entity<T> obj)
+        public bool Equals(Entity<T> obj)
         {
             if (ReferenceEquals(null, obj)) return false;
             if (ReferenceEquals(this, obj)) return true;
@@ -29,8 +30,8 @@ namespace MyMoney.Domain.Core
         {
             if (ReferenceEquals(null, obj)) return false;
             if (ReferenceEquals(this, obj)) return true;
-            if (obj.GetType() != typeof (entity<T>)) return false;
-            return Equals((entity<T>) obj);
+            if (obj.GetType() != typeof (Entity<T>)) return false;
+            return Equals((Entity<T>) obj);
         }
 
         public override int GetHashCode()
trunk/src/MyMoney/Infrastructure/interceptors/unit_of_work_interceptor.cs → trunk/src/MyMoney/Infrastructure/interceptors/UnitOfWorkInterceptor.cs
@@ -9,12 +9,12 @@ namespace MyMoney.Infrastructure.interceptors
     {
     }
 
-    public class unit_of_work_interceptor : IUnitOfWorkInterceptor
+    public class UnitOfWorkInterceptor : IUnitOfWorkInterceptor
     {
         readonly IUnitOfWorkRegistry registry;
         readonly IEventAggregator broker;
 
-        public unit_of_work_interceptor(IUnitOfWorkRegistry registry, IEventAggregator broker)
+        public UnitOfWorkInterceptor(IUnitOfWorkRegistry registry, IEventAggregator broker)
         {
             this.registry = registry;
             this.broker = broker;
@@ -25,8 +25,11 @@ namespace MyMoney.Infrastructure.interceptors
             using (registry)
             {
                 invocation.Proceed();
-                registry.commit_all();
-                broker.publish<unsaved_changes_event>();
+                if (registry.has_changes_to_commit())
+                {
+                    registry.commit_all();
+                    broker.publish<unsaved_changes_event>();
+                }
             }
         }
     }
trunk/src/MyMoney/Infrastructure/interceptors/UnitOfWorkInterceptorSpecs.cs
@@ -0,0 +1,7 @@
+namespace MyMoney.Infrastructure.interceptors
+{
+    public class UnitOfWorkInterceptorSpecs
+    {
+        
+    }
+}
\ No newline at end of file
trunk/src/MyMoney/Infrastructure/transactions/IUnitOfWorkRegistration.cs
@@ -0,0 +1,8 @@
+namespace MyMoney.Infrastructure.transactions
+{
+    public interface IUnitOfWorkRegistration<T>
+    {
+        T current { get; }
+        bool contains_changes();
+    }
+}
\ No newline at end of file
trunk/src/MyMoney/Infrastructure/transactions/IUnitOfWorkRegistrationFactory.cs
@@ -0,0 +1,8 @@
+using MyMoney.Utility.Core;
+
+namespace MyMoney.Infrastructure.transactions
+{
+    public interface IUnitOfWorkRegistrationFactory<T> : IMapper<T, IUnitOfWorkRegistration<T>>
+    {
+    }
+}
\ No newline at end of file
trunk/src/MyMoney/Infrastructure/transactions/null_unit_of_work.cs
@@ -1,16 +0,0 @@
-using MyMoney.Domain.Core;
-
-namespace MyMoney.Infrastructure.transactions
-{
-    internal class null_unit_of_work<T> : IUnitOfWork<T> where T : IEntity
-    {
-        public void register(T entity)
-        {}
-
-        public void commit()
-        {}
-
-        public void Dispose()
-        {}
-    }
-}
\ No newline at end of file
trunk/src/MyMoney/Infrastructure/transactions/NullUnitOfWork.cs
@@ -0,0 +1,24 @@
+using MyMoney.Domain.Core;
+
+namespace MyMoney.Infrastructure.transactions
+{
+    internal class NullUnitOfWork<T> : IUnitOfWork<T> where T : IEntity
+    {
+        public void register(T entity)
+        {
+        }
+
+        public void commit()
+        {
+        }
+
+        public bool is_dirty()
+        {
+            return false;
+        }
+
+        public void Dispose()
+        {
+        }
+    }
+}
\ No newline at end of file
trunk/src/MyMoney/Infrastructure/transactions/unit_of_work.cs
@@ -1,4 +1,5 @@
 using System;
+using System.Linq;
 using System.Collections.Generic;
 using MyMoney.Domain.Core;
 using MyMoney.Utility.Extensions;
@@ -8,6 +9,7 @@ namespace MyMoney.Infrastructure.transactions
     public interface IUnitOfWork : IDisposable
     {
         void commit();
+        bool is_dirty();
     }
 
     public interface IUnitOfWork<T> : IUnitOfWork where T : IEntity
@@ -17,23 +19,30 @@ namespace MyMoney.Infrastructure.transactions
 
     public class unit_of_work<T> : IUnitOfWork<T> where T : IEntity
     {
-        private readonly IRepository repository;
-        private readonly IList<T> registered_items;
+        readonly IRepository repository;
+        readonly IUnitOfWorkRegistrationFactory<T> mapper;
+        readonly IList<IUnitOfWorkRegistration<T>> registered_items;
 
-        public unit_of_work(IRepository repository)
+        public unit_of_work(IRepository repository, IUnitOfWorkRegistrationFactory<T> mapper)
         {
             this.repository = repository;
-            registered_items = new List<T>();
+            this.mapper = mapper;
+            registered_items = new List<IUnitOfWorkRegistration<T>>();
         }
 
         public void register(T entity)
         {
-            registered_items.Add(entity);
+            registered_items.Add(mapper.map_from(entity));
         }
 
         public void commit()
         {
-            registered_items.each(x => repository.save(x));
+            registered_items.each(x => repository.save(x.current));
+        }
+
+        public bool is_dirty()
+        {
+            return registered_items.Count(x => x.contains_changes()) > 0;
         }
 
         public void Dispose()
@@ -41,4 +50,5 @@ namespace MyMoney.Infrastructure.transactions
             registered_items.Clear();
         }
     }
+
 }
\ No newline at end of file
trunk/src/MyMoney/Infrastructure/transactions/unit_of_work_factory.cs
@@ -9,7 +9,7 @@ namespace MyMoney.Infrastructure.transactions
 
     public class unit_of_work_factory : IUnitOfWorkFactory
     {
-        private readonly IRepository repository;
+        readonly IRepository repository;
 
         public unit_of_work_factory(IRepository repository)
         {
@@ -18,7 +18,7 @@ namespace MyMoney.Infrastructure.transactions
 
         public IUnitOfWork<T> create_for<T>() where T : IEntity
         {
-            return new unit_of_work<T>(repository);
+            return new unit_of_work<T>(repository, null);
         }
     }
 }
\ No newline at end of file
trunk/src/MyMoney/Infrastructure/transactions/unit_of_work_registry_specs.cs
@@ -3,16 +3,15 @@ using MyMoney.Domain.Core;
 using MyMoney.Testing.MetaData;
 using MyMoney.Testing.spechelpers.contexts;
 using MyMoney.Testing.spechelpers.core;
-using mocking_extensions=MyMoney.Testing.spechelpers.core.mocking_extensions;
 
 namespace MyMoney.Infrastructure.transactions
 {
-    [Concern(typeof (unit_of_work_registry))]
+    [Concern(typeof (UnitOfWorkRegistry))]
     public class behaves_like_unit_of_work_registery : concerns_for<IUnitOfWorkRegistry>
     {
         public override IUnitOfWorkRegistry create_sut()
         {
-            return new unit_of_work_registry(factory);
+            return new UnitOfWorkRegistry(factory);
         }
 
         context c = () => { factory = the_dependency<IUnitOfWorkFactory>(); };
@@ -22,14 +21,14 @@ namespace MyMoney.Infrastructure.transactions
 
     public class when_starting_a_unit_of_work_for_a_new_type : behaves_like_unit_of_work_registery
     {
-        it should_register_a_new_unit_of_work = () => mocking_extensions.was_told_to(factory, x => x.create_for<IEntity>());
+        it should_register_a_new_unit_of_work = () => factory.was_told_to(x => x.create_for<IEntity>());
 
         it should_return_the_new_unit_of_work = () => result.should_be_equal_to(unit_of_work);
 
         context c = () =>
                         {
                             unit_of_work = an<IUnitOfWork<IEntity>>();
-                            mocking_extensions.it_will_return(mocking_extensions.is_told_to(factory, x => x.create_for<IEntity>()), unit_of_work);
+                            factory.is_told_to(x => x.create_for<IEntity>()).it_will_return( unit_of_work);
                         };
 
         because b = () => { result = sut.start_unit_of_work_for<IEntity>(); };
@@ -47,8 +46,7 @@ namespace MyMoney.Infrastructure.transactions
                         {
                             unit_of_work = an<IUnitOfWork<IEntity>>();
 
-                            mocking_extensions.it_will_return(mocking_extensions.is_told_to(factory, x => x.create_for<IEntity>()), unit_of_work)
-                                .Repeat.Once();
+                            factory.is_told_to(x => x.create_for<IEntity>()).it_will_return( unit_of_work).Repeat.Once();
                         };
 
         because b = () =>
@@ -63,12 +61,12 @@ namespace MyMoney.Infrastructure.transactions
 
     public class when_committing_all_the_active_units_of_work : behaves_like_unit_of_work_registery
     {
-        it should_commit_each_one = () => mocking_extensions.was_told_to(unit_of_work, x => x.commit());
+        it should_commit_each_one = () => unit_of_work.was_told_to(x => x.commit());
 
         context c = () =>
                         {
                             unit_of_work = an<IUnitOfWork<IEntity>>();
-                            mocking_extensions.it_will_return(mocking_extensions.is_told_to(factory, x => x.create_for<IEntity>()), unit_of_work).Repeat.Once();
+                            factory.is_told_to(x => x.create_for<IEntity>()).it_will_return( unit_of_work).Repeat.Once();
                         };
 
         because b = () =>
trunk/src/MyMoney/Infrastructure/transactions/unit_of_work_specs.cs
@@ -7,7 +7,24 @@ using MyMoney.Testing.spechelpers.core;
 namespace MyMoney.Infrastructure.transactions
 {
     [Concern(typeof (unit_of_work<IEntity>))]
-    public class when_committing_a_unit_of_work : concerns_for<IUnitOfWork<IEntity>>
+    public class behaves_like_a_unit_of_work : concerns_for<IUnitOfWork<IEntity>, unit_of_work<IEntity>>
+    {
+        public override IUnitOfWork<IEntity> create_sut()
+        {
+            return new unit_of_work<IEntity>(repository, factory);
+        }
+
+        context c = () =>
+                        {
+                            repository = the_dependency<IRepository>();
+                            factory = the_dependency<IUnitOfWorkRegistrationFactory<IEntity>>();
+                        };
+
+        protected static IRepository repository;
+        protected static IUnitOfWorkRegistrationFactory<IEntity> factory;
+    }
+
+    public class when_committing_a_unit_of_work : behaves_like_a_unit_of_work
     {
         it should_save_each_registered_item = () =>
                                                   {
@@ -15,17 +32,21 @@ namespace MyMoney.Infrastructure.transactions
                                                       repository.was_told_to(x => x.save(second_item));
                                                   };
 
-        public override IUnitOfWork<IEntity> create_sut()
-        {
-            return new unit_of_work<IEntity>(repository);
-        }
-
         context c = () =>
                         {
-                            repository = an<IRepository>();
-
                             first_item = an<IEntity>();
                             second_item = an<IEntity>();
+
+                            var first_registration = an<IUnitOfWorkRegistration<IEntity>>();
+                            var second_registration = an<IUnitOfWorkRegistration<IEntity>>();
+
+                            when_the(factory).is_told_to(x => x.map_from(first_item)).it_will_return(first_registration);
+                            when_the(factory).is_told_to(x => x.map_from(second_item)).it_will_return(
+                                second_registration);
+                            when_the(first_registration).is_told_to(x => x.contains_changes()).it_will_return(true);
+                            when_the(second_registration).is_told_to(x => x.contains_changes()).it_will_return(true);
+                            when_the(first_registration).is_told_to(x => x.current).it_will_return(first_item);
+                            when_the(second_registration).is_told_to(x => x.current).it_will_return(second_item);
                         };
 
         because b = () =>
@@ -35,8 +56,54 @@ namespace MyMoney.Infrastructure.transactions
                             sut.commit();
                         };
 
-        static IRepository repository;
         static IEntity first_item;
         static IEntity second_item;
     }
+
+    public class when_checking_if_there_are_changes_and_there_are : behaves_like_a_unit_of_work
+    {
+        it should_tell_the_truth = () => result.should_be_true();
+
+        context c = () =>
+                        {
+                            first_item = an<IEntity>();
+                            var first_registration = an<IUnitOfWorkRegistration<IEntity>>();
+
+                            when_the(factory).is_told_to(x => x.map_from(first_item)).it_will_return(first_registration);
+                            when_the(first_registration).is_told_to(x => x.contains_changes()).it_will_return(true);
+                            when_the(first_registration).is_told_to(x => x.current).it_will_return(first_item);
+                        };
+
+        because b = () =>
+                        {
+                            sut.register(first_item);
+                            result = sut.is_dirty();
+                        };
+
+        static bool result;
+        static IEntity first_item;
+    }
+
+    public class when_checking_if_there_are_changes_and_there_are_not : behaves_like_a_unit_of_work
+    {
+        it should_tell_the_truth = () => result.should_be_false();
+
+        context c = () =>
+                        {
+                            first_item = an<IEntity>();
+                            var first_registration = an<IUnitOfWorkRegistration<IEntity>>();
+
+                            when_the(factory).is_told_to(x => x.map_from(first_item)).it_will_return(first_registration);
+                            when_the(first_registration).is_told_to(x => x.contains_changes()).it_will_return(false);
+                        };
+
+        because b = () =>
+                        {
+                            sut.register(first_item);
+                            result = sut.is_dirty();
+                        };
+
+        static bool result;
+        static IEntity first_item;
+    }
 }
\ No newline at end of file
trunk/src/MyMoney/Infrastructure/transactions/UnitOfWork.cs
@@ -5,12 +5,12 @@ namespace MyMoney.Infrastructure.transactions
 {
     public class UnitOfWork
     {
-        public static IUnitOfWork<T> start_for<T>() where T : IEntity
+        public static IUnitOfWork<T> For<T>() where T : IEntity
         {
             if (resolve.is_initialized()) {
                 return resolve.dependency_for<IUnitOfWorkRegistry>().start_unit_of_work_for<T>();
             }
-            return new null_unit_of_work<T>();
+            return new NullUnitOfWork<T>();
         }
     }
 }
\ No newline at end of file
trunk/src/MyMoney/Infrastructure/transactions/unit_of_work_registry.cs → trunk/src/MyMoney/Infrastructure/transactions/UnitOfWorkRegistry.cs
@@ -1,4 +1,5 @@
 using System;
+using System.Linq;
 using System.Collections.Generic;
 using Castle.Core;
 using MyMoney.Domain.Core;
@@ -10,16 +11,16 @@ namespace MyMoney.Infrastructure.transactions
     {
         void commit_all();
         IUnitOfWork<T> start_unit_of_work_for<T>() where T : IEntity;
-        void clear_all();
+        bool has_changes_to_commit();
     }
 
     [Singleton]
-    public class unit_of_work_registry : IUnitOfWorkRegistry
+    public class UnitOfWorkRegistry : IUnitOfWorkRegistry
     {
         private readonly IUnitOfWorkFactory factory;
         private readonly IDictionary<Type, IUnitOfWork> units_of_work;
 
-        public unit_of_work_registry(IUnitOfWorkFactory factory)
+        public UnitOfWorkRegistry(IUnitOfWorkFactory factory)
         {
             this.factory = factory;
             units_of_work = new Dictionary<Type, IUnitOfWork>();
@@ -36,6 +37,11 @@ namespace MyMoney.Infrastructure.transactions
             return new_unit_of_work;
         }
 
+        public bool has_changes_to_commit()
+        {
+            return units_of_work.Values.Count(x=>x.is_dirty()) > 0;
+        }
+
         public void commit_all()
         {
             if (contains_items_to_commit()) {
@@ -43,12 +49,12 @@ namespace MyMoney.Infrastructure.transactions
             }
         }
 
-        public void clear_all()
+        void clear_all()
         {
             units_of_work.Clear();
         }
 
-        public bool contains_items_to_commit()
+        bool contains_items_to_commit()
         {
             return units_of_work.Count > 0;
         }
trunk/src/MyMoney/Presentation/Model/Menu/File/Commands/open_command_specs.cs
@@ -54,7 +54,7 @@ namespace MyMoney.Presentation.Model.Menu.File.Commands
 
         because b = () => sut.saved();
 
-        static file file_path;
+        static Projects.ApplicationFile file_path;
     }
 
     public class when_opening_a_project_after_declining_to_save_the_previous_project :
@@ -72,7 +72,7 @@ namespace MyMoney.Presentation.Model.Menu.File.Commands
 
         because b = () => sut.not_saved();
 
-        static file file_path;
+        static Projects.ApplicationFile file_path;
     }
 
     public class
@@ -92,6 +92,6 @@ namespace MyMoney.Presentation.Model.Menu.File.Commands
 
         because b = () => sut.cancelled();
 
-        static file file_path;
+        static Projects.ApplicationFile file_path;
     }
 }
\ No newline at end of file
trunk/src/MyMoney/Presentation/Model/Menu/File/Commands/save_as_command_specs.cs
@@ -29,7 +29,7 @@ namespace MyMoney.Presentation.Model.Menu.File.Commands
         }
 
         static IProject current_project;
-        static file new_path;
+        static Projects.ApplicationFile new_path;
         static ISelectFileToSaveToDialog view;
     }
 }
\ No newline at end of file
trunk/src/MyMoney/Presentation/Model/Projects/current_project.cs
@@ -50,7 +50,7 @@ namespace MyMoney.Presentation.Model.Projects
         public void start_a_new_project()
         {
             current_file = null;
-            configuration.change_path_to((file) Path.GetTempFileName());
+            configuration.change_path_to((ApplicationFile) Path.GetTempFileName());
             changes_to_save = false;
             broker.publish(new new_project_opened(name()));
         }
trunk/src/MyMoney/Presentation/Model/Projects/file.cs
@@ -10,9 +10,9 @@ namespace MyMoney.Presentation.Model.Projects
         bool does_the_file_exist();
     }
 
-    internal class file : IFile
+    internal class ApplicationFile : IFile
     {
-        public file(string path)
+        public ApplicationFile(string path)
         {
             this.path = path;
         }
@@ -28,19 +28,31 @@ namespace MyMoney.Presentation.Model.Projects
         {
             this.log().debug("copying file {0} to {1}", path, file_to_overwrite.path);
             File.Copy(path, file_to_overwrite.path, true);
+
+            var fs = File.Open("C:\\yourfile.txt", FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
+
+            var reader = new StreamReader(fs);
+
+            while (!reader.EndOfStream)
+            {
+                var line = reader.ReadLine();
+            }
+
+            reader.Close();
+            fs.Close();
         }
 
-        public static implicit operator file(string file_path)
+        public static implicit operator ApplicationFile(string file_path)
         {
-            return new file(file_path);
+            return new ApplicationFile(file_path);
         }
 
-        public static implicit operator string(file file)
+        public static implicit operator string(ApplicationFile file)
         {
             return file.path;
         }
 
-        public bool Equals(file obj)
+        public bool Equals(ApplicationFile obj)
         {
             if (ReferenceEquals(null, obj)) return false;
             if (ReferenceEquals(this, obj)) return true;
@@ -51,8 +63,8 @@ namespace MyMoney.Presentation.Model.Projects
         {
             if (ReferenceEquals(null, obj)) return false;
             if (ReferenceEquals(this, obj)) return true;
-            if (obj.GetType() != typeof (file)) return false;
-            return Equals((file) obj);
+            if (obj.GetType() != typeof (ApplicationFile)) return false;
+            return Equals((ApplicationFile) obj);
         }
 
         public override int GetHashCode()
trunk/src/MyMoney/Presentation/Views/core/ApplicationDockedWindow.cs
@@ -1,6 +1,5 @@
 using System.Linq;
 using System.Windows.Forms;
-using MyMoney.Infrastructure.debugging;
 using MyMoney.Presentation.Resources;
 using WeifenLuo.WinFormsUI.Docking;
 
@@ -59,7 +58,6 @@ namespace MyMoney.Presentation.Views.core
 
         public void add_to(DockPanel panel)
         {
-            Launch.the_debugger();
             if (window_is_already_contained_in(panel))
             {
                 remove_from(panel);
trunk/src/MyMoney/Presentation/Views/dialogs/select_file_to_open_dialog.cs
@@ -20,7 +20,7 @@ namespace MyMoney.Presentation.Views.dialogs
         public IFile tell_me_the_path_to_the_file()
         {
             var result = dialog.ShowDialog();
-            var path_to_the_file = (file) (result.Equals(DialogResult.Cancel) ? string.Empty : dialog.FileName);
+            var path_to_the_file = (ApplicationFile) (result.Equals(DialogResult.Cancel) ? string.Empty : dialog.FileName);
             dialog.Dispose();
             return path_to_the_file;
         }
trunk/src/MyMoney/Presentation/Views/dialogs/select_file_to_save_to_dialog.cs
@@ -20,7 +20,7 @@ namespace MyMoney.Presentation.Views.dialogs
         public IFile tell_me_the_path_to_the_file()
         {
             var result = dialog.ShowDialog();
-            var the_path = (file) (result == DialogResult.Cancel ? string.Empty : dialog.FileName);
+            var the_path = (ApplicationFile) (result == DialogResult.Cancel ? string.Empty : dialog.FileName);
             dialog.Dispose();
             return the_path;
         }
trunk/src/MyMoney/Presentation/Views/Shell/NotificationIconView.cs
@@ -11,11 +11,11 @@ namespace MyMoney.Presentation.Views.Shell
     [Singleton]
     public class NotificationIconView : INotificationIconView
     {
-        NotifyIcon ux_notification_icon;
-        readonly IFileMenu file_menu;
-        readonly IWindowMenu window_menu;
-        readonly IHelpMenu help_menu;
-        bool hooked_up;
+        private NotifyIcon ux_notification_icon;
+        private readonly IFileMenu file_menu;
+        private readonly IWindowMenu window_menu;
+        private readonly IHelpMenu help_menu;
+        private bool hooked_up;
 
         public NotificationIconView(IFileMenu file_menu, IWindowMenu window_menu, IHelpMenu help_menu)
         {
@@ -54,7 +54,7 @@ namespace MyMoney.Presentation.Views.Shell
 
         public void opened_new_project()
         {
-            ux_notification_icon.ShowBalloonTip(100, "If you need any help check out mokhan.ca", "", ToolTipIcon.Info);
+            show_popup_message("If you need any help check out mokhan.ca");
         }
 
         public void show_popup_message(string message)
@@ -62,7 +62,7 @@ namespace MyMoney.Presentation.Views.Shell
             ux_notification_icon.ShowBalloonTip(100, message, message, ToolTipIcon.Info);
         }
 
-        MenuItem map_from(ISubMenu item)
+        private MenuItem map_from(ISubMenu item)
         {
             var toolStripMenuItem = new MenuItem(item.name);
             foreach (var menuItem in item.all_menu_items())
trunk/src/MyMoney/Tasks/application/billing_tasks.cs
@@ -42,7 +42,7 @@ namespace MyMoney.Tasks.application
 
         public void register_new_company(register_new_company dto)
         {
-            new company(dto.company_name);
+            new Company(dto.company_name);
         }
 
         public IEnumerable<ICompany> all_companys()
trunk/src/MyMoney/MyMoney.csproj
@@ -156,9 +156,9 @@
     </Reference>
   </ItemGroup>
   <ItemGroup>
-    <Compile Include="DataAccess\db40\connection_factory.cs" />
-    <Compile Include="DataAccess\db40\database_configuration.cs" />
-    <Compile Include="DataAccess\db40\db4o_repository.cs" />
+    <Compile Include="DataAccess\db40\ConnectionFactory.cs" />
+    <Compile Include="DataAccess\db40\DatabaseConfiguration.cs" />
+    <Compile Include="DataAccess\db40\ObjectRepository.cs" />
     <Compile Include="DataAccess\db40\db4o_repository_specs.cs" />
     <Compile Include="DataAccess\db40\spiking\db40_spike_specs.cs" />
     <Compile Include="DataAccess\repositories\bill_repository_specs.cs" />
@@ -210,7 +210,8 @@
     <Compile Include="Infrastructure\interceptors\lazy_loaded_interceptor.cs" />
     <Compile Include="Infrastructure\interceptors\logging_interceptor.cs" />
     <Compile Include="Infrastructure\interceptors\raise_event_interceptor.cs" />
-    <Compile Include="Infrastructure\interceptors\unit_of_work_interceptor.cs" />
+    <Compile Include="Infrastructure\interceptors\UnitOfWorkInterceptor.cs" />
+    <Compile Include="Infrastructure\interceptors\UnitOfWorkInterceptorSpecs.cs" />
     <Compile Include="Infrastructure\Logging\ILoggable.cs" />
     <Compile Include="Infrastructure\registries\default_registry.cs" />
     <Compile Include="Infrastructure\registries\default_registry_specs.cs" />
@@ -235,11 +236,13 @@
     <Compile Include="Infrastructure\Threading\worker_thread.cs">
       <SubType>Component</SubType>
     </Compile>
-    <Compile Include="Infrastructure\transactions\null_unit_of_work.cs" />
+    <Compile Include="Infrastructure\transactions\IUnitOfWorkRegistration.cs" />
+    <Compile Include="Infrastructure\transactions\IUnitOfWorkRegistrationFactory.cs" />
+    <Compile Include="Infrastructure\transactions\NullUnitOfWork.cs" />
     <Compile Include="Infrastructure\transactions\UnitOfWork.cs" />
     <Compile Include="Infrastructure\transactions\unit_of_work.cs" />
     <Compile Include="Infrastructure\transactions\unit_of_work_factory.cs" />
-    <Compile Include="Infrastructure\transactions\unit_of_work_registry.cs" />
+    <Compile Include="Infrastructure\transactions\UnitOfWorkRegistry.cs" />
     <Compile Include="Infrastructure\transactions\unit_of_work_registry_specs.cs" />
     <Compile Include="Infrastructure\transactions\unit_of_work_specs.cs" />
     <Compile Include="Presentation\Core\could_not_find_presenter.cs" />