Commit f153033
Changed files (8)
trunk
product
MyMoney
boot
container
registration
Infrastructure
transactions2
Presentation
Model
trunk/product/MyMoney/boot/container/registration/wire_up_the_data_access_components_into_the.cs
@@ -18,7 +18,6 @@ namespace MoMoney.boot.container.registration
public void run()
{
register.singleton<ISessionContext, SessionContext>();
- //register.singleton<IDatabaseConfiguration, DatabaseConfiguration>();
register.singleton<IDatabase, Database>();
register.singleton(() => resolve.dependency_for<IDatabase>().downcast_to<IDatabaseConfiguration>());
}
trunk/product/MyMoney/Infrastructure/transactions2/Database.cs
@@ -34,11 +34,6 @@ namespace MoMoney.Infrastructure.transactions2
}
}
- public IFile path_to_database()
- {
- return path;
- }
-
public void open(IFile file)
{
path = new ApplicationFile(Path.GetTempFileName());
@@ -49,5 +44,10 @@ namespace MoMoney.Infrastructure.transactions2
{
path.copy_to(new_path);
}
+
+ IFile path_to_database()
+ {
+ return path;
+ }
}
}
\ No newline at end of file
trunk/product/MyMoney/Infrastructure/transactions2/DatabaseConfiguration.cs
@@ -1,45 +0,0 @@
-using System.IO;
-using MoMoney.Infrastructure.eventing;
-using MoMoney.Presentation.Model.messages;
-using MoMoney.Presentation.Model.Projects;
-
-namespace MoMoney.Infrastructure.transactions2
-{
- public interface IDatabaseConfiguration
- {
- IFile path_to_database();
- void open(IFile file);
- void copy_to(string path);
- }
-
- //public class DatabaseConfiguration : IDatabaseConfiguration, IEventSubscriber<NewProjectOpened>
- //{
- // IFile path;
-
- // public DatabaseConfiguration()
- // {
- // path = new ApplicationFile(Path.GetTempFileName());
- // }
-
- // public IFile path_to_database()
- // {
- // return path;
- // }
-
- // public void open(IFile file)
- // {
- // path = new ApplicationFile(Path.GetTempFileName());
- // file.copy_to(path.path);
- // }
-
- // public void copy_to(string new_path)
- // {
- // path.copy_to(new_path);
- // }
-
- // public void notify(NewProjectOpened message)
- // {
- // path = new ApplicationFile(Path.GetTempFileName());
- // }
- //}
-}
\ No newline at end of file
trunk/product/MyMoney/Infrastructure/transactions2/IDatabaseConfiguration.cs
@@ -0,0 +1,10 @@
+using MoMoney.Presentation.Model.Projects;
+
+namespace MoMoney.Infrastructure.transactions2
+{
+ public interface IDatabaseConfiguration
+ {
+ void open(IFile file);
+ void copy_to(string path);
+ }
+}
\ No newline at end of file
trunk/product/MyMoney/Presentation/Model/Projects/IProject.cs
@@ -0,0 +1,9 @@
+namespace MoMoney.Presentation.Model.Projects
+{
+ public interface IProject
+ {
+ string name();
+ bool is_file_specified();
+ bool is_open();
+ }
+}
\ No newline at end of file
trunk/product/MyMoney/Presentation/Model/Projects/IProjectController.cs
@@ -0,0 +1,15 @@
+namespace MoMoney.Presentation.Model.Projects
+{
+ public interface IProjectController
+ {
+ string name();
+ void start_new_project();
+ void open_project_from(IFile file);
+ void save_changes();
+ void save_project_to(IFile new_file);
+ void close_project();
+ bool has_been_saved_at_least_once();
+ bool has_unsaved_changes();
+ bool is_open();
+ }
+}
\ No newline at end of file
trunk/product/MyMoney/Presentation/Model/Projects/ProjectController.cs
@@ -1,3 +1,4 @@
+using System;
using MoMoney.Infrastructure.eventing;
using MoMoney.Infrastructure.transactions2;
using MoMoney.Presentation.Model.messages;
@@ -5,25 +6,11 @@ using MoMoney.Utility.Extensions;
namespace MoMoney.Presentation.Model.Projects
{
- public interface IProjectController
- {
- string name();
- void start_new_project();
- void open_project_from(IFile file);
- void save_changes();
- void save_project_to(IFile new_file);
- void close_project();
- bool has_been_saved_at_least_once();
- bool has_unsaved_changes();
- bool is_open();
- }
-
public class ProjectController : IProjectController, IEventSubscriber<UnsavedChangesEvent>
{
readonly IEventAggregator broker;
readonly IDatabaseConfiguration configuration;
- IFile current_file;
- bool is_project_open = false;
+ IProject project;
bool unsaved_changes = false;
public ProjectController(IEventAggregator broker, IDatabaseConfiguration configuration)
@@ -31,18 +18,18 @@ namespace MoMoney.Presentation.Model.Projects
this.broker = broker;
this.configuration = configuration;
broker.subscribe(this);
+ project = new EmptyProject();
}
public string name()
{
- return has_been_saved_at_least_once() ? current_file.path : "untitled.mo";
+ return project.name();
}
public void start_new_project()
{
close_project();
- is_project_open = true;
- current_file = null;
+ project = new Project(null);
broker.publish(new NewProjectOpened(name()));
}
@@ -51,15 +38,14 @@ namespace MoMoney.Presentation.Model.Projects
if (!file.does_the_file_exist()) return;
close_project();
configuration.open(file);
- current_file = file;
- is_project_open = true;
+ project = new Project(file);
broker.publish(new NewProjectOpened(name()));
}
public void save_changes()
{
ensure_that_a_path_to_save_to_has_been_specified();
- configuration.copy_to(current_file.path);
+ configuration.copy_to(project.name());
unsaved_changes = false;
broker.publish<SavedChangesEvent>();
}
@@ -67,21 +53,20 @@ namespace MoMoney.Presentation.Model.Projects
public void save_project_to(IFile new_file)
{
if (new_file.path.is_blank()) return;
- current_file = new_file;
+ project = new Project(new_file);
save_changes();
}
public void close_project()
{
- if (!is_project_open) return;
- is_project_open = false;
- current_file = null;
+ if (!project.is_open()) return;
+ project = new EmptyProject();
broker.publish<ClosingProjectEvent>();
}
public bool has_been_saved_at_least_once()
{
- return current_file != null;
+ return project.is_file_specified();
}
public bool has_unsaved_changes()
@@ -91,15 +76,12 @@ namespace MoMoney.Presentation.Model.Projects
public bool is_open()
{
- return is_project_open;
+ return project.is_open();
}
void ensure_that_a_path_to_save_to_has_been_specified()
{
- if (!has_been_saved_at_least_once())
- {
- throw new FileNotSpecifiedException();
- }
+ if (!has_been_saved_at_least_once()) throw new FileNotSpecifiedException();
}
public void notify(UnsavedChangesEvent message)
@@ -107,4 +89,47 @@ namespace MoMoney.Presentation.Model.Projects
unsaved_changes = true;
}
}
+
+ public class EmptyProject : IProject
+ {
+ public string name()
+ {
+ return "untitled.mo";
+ }
+
+ public bool is_file_specified()
+ {
+ return false;
+ }
+
+ public bool is_open()
+ {
+ return false;
+ }
+ }
+
+ public class Project : IProject
+ {
+ readonly IFile file;
+
+ public Project(IFile file)
+ {
+ this.file = file;
+ }
+
+ public string name()
+ {
+ return is_file_specified() ? file.path : "untitled.mo";
+ }
+
+ public bool is_file_specified()
+ {
+ return file != null;
+ }
+
+ public bool is_open()
+ {
+ return true;
+ }
+ }
}
\ No newline at end of file
trunk/product/MyMoney/MyMoney.csproj
@@ -223,11 +223,11 @@
<Compile Include="Infrastructure\transactions2\ConnectionFactory.cs" />
<Compile Include="Infrastructure\transactions2\Context.cs" />
<Compile Include="Infrastructure\transactions2\Database.cs" />
- <Compile Include="Infrastructure\transactions2\DatabaseConfiguration.cs" />
<Compile Include="Infrastructure\transactions2\DatabaseConnection.cs" />
<Compile Include="Infrastructure\transactions2\EmptyUnitOfWork.cs" />
<Compile Include="Infrastructure\transactions2\IChangeTracker.cs" />
<Compile Include="Infrastructure\transactions2\IChangeTrackerFactory.cs" />
+ <Compile Include="Infrastructure\transactions2\IDatabaseConfiguration.cs" />
<Compile Include="Infrastructure\transactions2\IdentityMapProxy.cs" />
<Compile Include="Infrastructure\transactions2\IdentityMapSpecs.cs" />
<Compile Include="Infrastructure\transactions2\IIdentityMap.cs" />
@@ -373,6 +373,8 @@
<Compile Include="Presentation\Model\Navigation\branches\AddNewIncomeBranch.cs" />
<Compile Include="Presentation\Model\Navigation\branches\view_all_bills_branch.cs" />
<Compile Include="Presentation\Model\Navigation\branches\view_all_bills_report_branch.cs" />
+ <Compile Include="Presentation\Model\Projects\IProject.cs" />
+ <Compile Include="Presentation\Model\Projects\IProjectController.cs" />
<Compile Include="Presentation\Model\Projects\ProjectController.cs" />
<Compile Include="Presentation\Core\PresenterRegistry.cs" />
<Compile Include="Presentation\Model\Menu\create.cs" />