Commit 3ff6a58
Changed files (38)
product
client
boot
boot
container
registration
database
transactions
presentation
Model
Menu
Reporting
Presenters
presentation.windows
bootstrappers
commands
presenters
service
infrastructure
views
presentation.winforms
helpers
service.contracts
service.infrastructure
threading
product/client/boot/boot/container/registration/IContainerStartup.cs
@@ -3,5 +3,5 @@ using gorilla.commons.utility;
namespace MoMoney.boot.container.registration
{
- public interface IContainerStartup : ArgCommand<DependencyRegistration> { }
+ public interface IContainerStartup : Command<DependencyRegistration> { }
}
\ No newline at end of file
product/client/boot/boot/container/registration/IStartupCommand.cs
@@ -3,5 +3,5 @@ using gorilla.commons.utility;
namespace MoMoney.boot.container.registration
{
- public interface IStartupCommand : ArgCommand<Assembly> {}
+ public interface IStartupCommand : Command<Assembly> {}
}
\ No newline at end of file
product/client/database/transactions/DatabaseCommand.cs
@@ -2,5 +2,5 @@ using gorilla.commons.utility;
namespace momoney.database.transactions
{
- public interface DatabaseCommand : ArgCommand<DatabaseConnection> {}
+ public interface DatabaseCommand : Command<DatabaseConnection> {}
}
\ No newline at end of file
product/client/presentation/Model/Menu/File/ISaveChangesCommand.cs
@@ -2,5 +2,5 @@ using gorilla.commons.utility;
namespace MoMoney.Presentation.Model.Menu.File
{
- public interface ISaveChangesCommand : ArgCommand<ISaveChangesCallback> {}
+ public interface ISaveChangesCommand : Command<ISaveChangesCallback> {}
}
\ No newline at end of file
product/client/presentation/Model/Reporting/IBindReportTo.cs
@@ -2,5 +2,5 @@ using gorilla.commons.utility;
namespace MoMoney.Presentation.Model.reporting
{
- public interface IBindReportTo<T, TQuery> : IReport, ArgCommand<T> where TQuery : Query<T> {}
+ public interface IBindReportTo<T, TQuery> : IReport, Command<T> where TQuery : Query<T> {}
}
\ No newline at end of file
product/client/presentation/Presenters/CommandPump.cs
@@ -8,7 +8,7 @@ namespace MoMoney.Presentation.Presenters
public interface ICommandPump
{
ICommandPump run<Command>() where Command : gorilla.commons.utility.Command;
- ICommandPump run<Command, T>(T input) where Command : ArgCommand<T>;
+ ICommandPump run<Command, T>(T input) where Command : Command<T>;
ICommandPump run<Output, Query>(Callback<Output> item) where Query : Query<Output>;
}
@@ -36,7 +36,7 @@ namespace MoMoney.Presentation.Presenters
return this;
}
- public ICommandPump run<Command, T>(T input) where Command : ArgCommand<T>
+ public ICommandPump run<Command, T>(T input) where Command : Command<T>
{
var cached = input;
var command = registry.get_a<Command>();
product/client/presentation/Presenters/ProcessQueryCommand.cs
@@ -4,7 +4,7 @@ using momoney.service.infrastructure.threading;
namespace MoMoney.Presentation.Presenters
{
- public interface IProcessQueryCommand<T> : ArgCommand<Callback<T>> {}
+ public interface IProcessQueryCommand<T> : Command<Callback<T>> {}
public class ProcessQueryCommand<T> : IProcessQueryCommand<T>
{
product/client/presentation.windows/bootstrappers/Bootstrapper.cs
@@ -1,5 +1,4 @@
using System.Collections.Generic;
-using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Threading;
@@ -65,17 +64,19 @@ namespace presentation.windows.bootstrappers
//builder.Register(x => AsyncOperationManager.SynchronizationContext);
builder.Register(x => SynchronizationContext.Current);
-
// presenters
builder.Register<StatusBarPresenter>().SingletonScoped();
builder.Register<CompensationPresenter>().SingletonScoped();
builder.Register<SelectedFamilyMemberPresenter>().SingletonScoped();
builder.Register<AddFamilyMemberPresenter>();
+ builder.Register<SaveCommand>();
+ builder.Register<CancelCommand>();
// commanding
builder.Register<ContainerCommandBuilder>().As<CommandBuilder>().SingletonScoped();
builder.Register<AsynchronousCommandProcessor>().As<CommandProcessor>().SingletonScoped();
builder.Register<AddFamilyMemberCommand>();
+ builder.Register<WpfCommandBuilder>().As<UICommandBuilder>();
// queries
builder.Register<FindMemberIdentifiedBy>();
@@ -88,6 +89,7 @@ namespace presentation.windows.bootstrappers
Resolve.the<IEnumerable<NeedStartup>>().each(x => x.run());
Resolve.the<CommandProcessor>().run();
+ shell_window.Closed += (sender, args) => Resolve.the<CommandProcessor>().stop();
return shell_window;
}
product/client/presentation.windows/commands/AddFamilyMemberCommand.cs
@@ -7,7 +7,7 @@ using presentation.windows.orm;
namespace presentation.windows.commands
{
- public class AddFamilyMemberCommand : ArgCommand<FamilyMemberToAdd>
+ public class AddFamilyMemberCommand : Command<FamilyMemberToAdd>
{
PersonRepository people;
EventAggregator event_aggregator;
@@ -28,5 +28,10 @@ namespace presentation.windows.commands
first_name = person.first_name,
});
}
+
+ public override string ToString()
+ {
+ return "Adding Family Member";
+ }
}
}
\ No newline at end of file
product/client/presentation.windows/commands/CommandBuilder.cs
@@ -4,8 +4,12 @@ namespace presentation.windows.commands
{
public interface CommandBuilder
{
- ParameterizedCommandBuilder<TData> prepare<TData>(TData data);
+ CommandBuilder<TData> prepare<TData>(TData data);
Command build<TCommand>(string message) where TCommand : Command;
}
+ public interface CommandBuilder<T>
+ {
+ Command build<TCommand>(string message) where TCommand : Command<T>;
+ }
}
\ No newline at end of file
product/client/presentation.windows/commands/ContainerAwareParameterizedCommandBuilder.cs โ product/client/presentation.windows/commands/ContainerAwareCommandBuilder.cs
@@ -6,21 +6,21 @@ using momoney.service.infrastructure.transactions;
namespace presentation.windows.commands
{
- public class ContainerAwareParameterizedCommandBuilder<T> : ParameterizedCommandBuilder<T>, Command
+ public class ContainerAwareCommandBuilder<T> : CommandBuilder<T>, Command
{
readonly T data;
Action action;
EventAggregator event_broker;
IUnitOfWorkFactory factory;
- public ContainerAwareParameterizedCommandBuilder(T data, EventAggregator event_broker, IUnitOfWorkFactory factory)
+ public ContainerAwareCommandBuilder(T data, EventAggregator event_broker, IUnitOfWorkFactory factory)
{
this.data = data;
this.factory = factory;
this.event_broker = event_broker;
}
- public Command build<TCommand>(string message) where TCommand : ArgCommand<T>
+ public Command build<TCommand>(string message) where TCommand : Command<T>
{
action = () =>
{
product/client/presentation.windows/commands/ContainerCommandBuilder.cs
@@ -16,9 +16,9 @@ namespace presentation.windows.commands
this.unit_of_work_factory = unit_of_work_factory;
}
- public ParameterizedCommandBuilder<T> prepare<T>(T data)
+ public CommandBuilder<T> prepare<T>(T data)
{
- return new ContainerAwareParameterizedCommandBuilder<T>(data, event_aggregator, unit_of_work_factory);
+ return new ContainerAwareCommandBuilder<T>(data, event_aggregator, unit_of_work_factory);
}
public Command build<T>(string message) where T : Command
product/client/presentation.windows/commands/ParameterizedCommandBuilder.cs
@@ -1,9 +0,0 @@
-using gorilla.commons.utility;
-
-namespace presentation.windows.commands
-{
- public interface ParameterizedCommandBuilder<T>
- {
- Command build<TCommand>(string message) where TCommand : ArgCommand<T>;
- }
-}
\ No newline at end of file
product/client/presentation.windows/presenters/AddFamilyMemberPresenter.cs
@@ -1,41 +1,21 @@
using System;
using Gorilla.Commons.Utility;
-using MoMoney.Service.Infrastructure.Threading;
-using presentation.windows.commands;
-using presentation.windows.commands.dto;
namespace presentation.windows.presenters
{
public class AddFamilyMemberPresenter : DialogPresenter
{
- CommandBuilder command_builder;
- CommandProcessor processor;
+ UICommandBuilder ui_builder;
- public AddFamilyMemberPresenter(CommandBuilder command_builder, CommandProcessor processor)
+ public AddFamilyMemberPresenter(UICommandBuilder ui_builder)
{
- this.command_builder = command_builder;
- this.processor = processor;
+ this.ui_builder = ui_builder;
}
public void present()
{
- Save = new SimpleCommand(() =>
- {
- processor.add(command_builder
- .prepare(new FamilyMemberToAdd
- {
- first_name = first_name,
- last_name = last_name,
- date_of_birth = date_of_birth
- })
- .build<AddFamilyMemberCommand>("Adding Family Member")
- );
- close();
- });
- Cancel = new SimpleCommand(() =>
- {
- close();
- });
+ Save = ui_builder.build<SaveCommand>(this);
+ Cancel = ui_builder.build<CancelCommand>(this);
date_of_birth = Clock.today();
}
product/client/presentation.windows/presenters/CancelCommand.cs
@@ -0,0 +1,10 @@
+namespace presentation.windows.presenters
+{
+ public class CancelCommand : UICommand<DialogPresenter>
+ {
+ protected override void run(DialogPresenter presenter)
+ {
+ presenter.close();
+ }
+ }
+}
\ No newline at end of file
product/client/presentation.windows/presenters/SaveCommand.cs
@@ -0,0 +1,32 @@
+using MoMoney.Service.Infrastructure.Threading;
+using presentation.windows.commands;
+using presentation.windows.commands.dto;
+
+namespace presentation.windows.presenters
+{
+ public class SaveCommand : UICommand<AddFamilyMemberPresenter>
+ {
+ CommandBuilder command_builder;
+ CommandProcessor processor;
+
+ public SaveCommand(CommandBuilder command_builder, CommandProcessor processor)
+ {
+ this.command_builder = command_builder;
+ this.processor = processor;
+ }
+
+ protected override void run(AddFamilyMemberPresenter presenter)
+ {
+ processor.add(command_builder
+ .prepare(new FamilyMemberToAdd
+ {
+ first_name = presenter.first_name,
+ last_name = presenter.last_name,
+ date_of_birth = presenter.date_of_birth
+ })
+ .build<AddFamilyMemberCommand>("Adding Family Member")
+ );
+ presenter.close();
+ }
+ }
+}
\ No newline at end of file
product/client/presentation.windows/presenters/SelectedFamilyMemberPresenter.cs
@@ -1,4 +1,4 @@
-using System.Collections.ObjectModel;
+using System.Collections.Generic;
using MoMoney.Service.Infrastructure.Eventing;
using presentation.windows.events;
using presentation.windows.queries;
@@ -17,7 +17,7 @@ namespace presentation.windows.presenters
this.event_aggregator = event_aggregator;
}
- public ObservableCollection<PersonDetails> family_members { get; set; }
+ public ICollection<PersonDetails> family_members { get; set; }
public PersonDetails SelectedMember
{
product/client/presentation.windows/presenters/UICommand.cs
@@ -0,0 +1,17 @@
+namespace presentation.windows.presenters
+{
+ public interface UICommand
+ {
+ void run<T>(T presenter) where T : Presenter;
+ }
+
+ public abstract class UICommand<T> : UICommand where T : class, Presenter
+ {
+ void UICommand.run<T1>(T1 presenter)
+ {
+ run(presenter as T);
+ }
+
+ protected abstract void run(T presenter);
+ }
+}
\ No newline at end of file
product/client/presentation.windows/presenters/UICommandBuilder.cs
@@ -0,0 +1,7 @@
+namespace presentation.windows.presenters
+{
+ public interface UICommandBuilder
+ {
+ IObservableCommand build<T>(Presenter presenter) where T : UICommand;
+ }
+}
\ No newline at end of file
product/client/presentation.windows/presenters/WpfCommandBuilder.cs
@@ -0,0 +1,23 @@
+using Autofac;
+
+namespace presentation.windows.presenters
+{
+ public class WpfCommandBuilder : UICommandBuilder
+ {
+ IContainer container;
+
+ public WpfCommandBuilder(IContainer container)
+ {
+ this.container = container;
+ }
+
+ public IObservableCommand build<T>(Presenter presenter) where T : UICommand
+ {
+ var command = container.Resolve<T>();
+ return new SimpleCommand(() =>
+ {
+ command.run(presenter);
+ });
+ }
+ }
+}
\ No newline at end of file
product/client/presentation.windows/service/infrastructure/ServiceBus.cs
@@ -0,0 +1,9 @@
+using gorilla.commons.utility;
+
+namespace presentation.windows.service.infrastructure
+{
+ public interface ServiceBus
+ {
+ void run<T>(Command<T> command, T item);
+ }
+}
\ No newline at end of file
product/client/presentation.windows/views/ShellWIndow.xaml
@@ -2,7 +2,7 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:ui="clr-namespace:presentation.windows.views" Title="MoMoney - (ALPHA)" MinWidth="1024" MinHeight="768" WindowStartupLocation="CenterScreen" WindowState="Maximized">
<DockPanel VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
- <ui:MainMenu x:Name="Menu" DockPanel.Dock="Top">
+ <ui:MainMenu x:Name="Menu" DockPanel.Dock="Top" HorizontalAlignment="Right">
</ui:MainMenu>
<ui:StatusBarRegion x:Name="StatusBar" DockPanel.Dock="Bottom"></ui:StatusBarRegion>
<StackPanel>
product/client/presentation.windows/DialogPresenter.cs
@@ -4,6 +4,6 @@ namespace presentation.windows
{
public interface DialogPresenter : Presenter
{
- Action close { set; }
+ Action close { get; set; }
}
}
\ No newline at end of file
product/client/presentation.windows/presentation.windows.csproj
@@ -134,7 +134,6 @@
<Compile Include="orm\nhibernate\NHibernateUnitOfWorkFactory.cs" />
<Compile Include="orm\nhibernate\NHibernateUnitOfWork.cs" />
<Compile Include="infrastructure\DefaultMapper.cs" />
- <Compile Include="commands\ParameterizedCommandBuilder.cs" />
<Compile Include="domain\Entity.cs" />
<Compile Include="events\AddedNewFamilyMember.cs" />
<Compile Include="commands\UpdateOnLongRunningProcess.cs" />
@@ -149,12 +148,17 @@
<Compile Include="presenters\AddFamilyMemberPresenter.cs" />
<Compile Include="commands\CommandBuilder.cs" />
<Compile Include="commands\AddFamilyMemberCommand.cs" />
+ <Compile Include="presenters\CancelCommand.cs" />
<Compile Include="presenters\CompensationPresenter.cs" />
<Compile Include="commands\dto\FamilyMemberToAdd.cs" />
<Compile Include="commands\ContainerCommandBuilder.cs" />
<Compile Include="commands\NamedCommand.cs" />
- <Compile Include="commands\ContainerAwareParameterizedCommandBuilder.cs" />
+ <Compile Include="commands\ContainerAwareCommandBuilder.cs" />
+ <Compile Include="presenters\SaveCommand.cs" />
+ <Compile Include="presenters\UICommand.cs" />
+ <Compile Include="presenters\UICommandBuilder.cs" />
<Compile Include="presenters\WpfBindingExtensinos.cs" />
+ <Compile Include="presenters\WpfCommandBuilder.cs" />
<Compile Include="queries\ContainerAwareQueryBuilder.cs" />
<Compile Include="queries\FindAllFamily.cs" />
<Compile Include="queries\FindMemberIdentifiedBy.cs" />
@@ -163,6 +167,7 @@
<Compile Include="presenters\Observable.cs" />
<Compile Include="queries\PersonDetails.cs" />
<Compile Include="queries\QueryBuilder.cs" />
+ <Compile Include="service\infrastructure\ServiceBus.cs" />
<Compile Include="View.cs" />
<Compile Include="views\AddFamilyMemberDialog.xaml.cs">
<DependentUpon>AddFamilyMemberDialog.xaml</DependentUpon>
@@ -253,6 +258,10 @@
<ItemGroup>
<Resource Include="log4net.config.xml" />
</ItemGroup>
+ <ItemGroup>
+ <Folder Include="service\application\" />
+ <Folder Include="service\domain\" />
+ </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
product/client/presentation.windows/Program.cs
@@ -1,6 +1,7 @@
using System;
using System.Security.Principal;
using System.Windows;
+using System.Windows.Threading;
using presentation.windows.bootstrappers;
using presentation.windows.views;
@@ -12,13 +13,14 @@ namespace presentation.windows
static public void Main()
{
AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);
- var application = new Application();
- application.DispatcherUnhandledException += (o, e) =>
+ Dispatcher.CurrentDispatcher.UnhandledException += (o, e) =>
{
new ErrorWindow {DataContext = e.Exception}.ShowDialog();
};
- application.ShutdownMode = ShutdownMode.OnMainWindowClose;
- application.Run(Bootstrapper.create_window());
+ new Application
+ {
+ ShutdownMode = ShutdownMode.OnMainWindowClose
+ }.Run(Bootstrapper.create_window());
}
}
}
\ No newline at end of file
product/client/presentation.winforms/helpers/ITextBoxCommand.cs
@@ -2,5 +2,5 @@ using gorilla.commons.utility;
namespace MoMoney.Presentation.Winforms.Helpers
{
- public interface ITextBoxCommand<T> : ArgCommand<IBindableTextBox<T>> {}
+ public interface ITextBoxCommand<T> : Command<IBindableTextBox<T>> {}
}
\ No newline at end of file
product/client/service.contracts/Application/IAddNewIncomeCommand.cs
@@ -5,5 +5,5 @@ using MoMoney.DTO;
namespace MoMoney.Service.Contracts.Application
{
[ServiceContract]
- public interface IAddNewIncomeCommand : ArgCommand<IncomeSubmissionDTO> {}
+ public interface IAddNewIncomeCommand : Command<IncomeSubmissionDTO> {}
}
\ No newline at end of file
product/client/service.contracts/Application/IRegisterNewCompanyCommand.cs
@@ -5,5 +5,5 @@ using MoMoney.DTO;
namespace MoMoney.Service.Contracts.Application
{
[ServiceContract]
- public interface IRegisterNewCompanyCommand : ArgCommand<RegisterNewCompany> {}
+ public interface IRegisterNewCompanyCommand : Command<RegisterNewCompany> {}
}
\ No newline at end of file
product/client/service.contracts/Application/ISaveNewBillCommand.cs
@@ -5,5 +5,5 @@ using MoMoney.DTO;
namespace MoMoney.Service.Contracts.Application
{
[ServiceContract]
- public interface ISaveNewBillCommand : ArgCommand<AddNewBillDTO> {}
+ public interface ISaveNewBillCommand : Command<AddNewBillDTO> {}
}
\ No newline at end of file
product/client/service.infrastructure/threading/SynchronizedCommand.cs
@@ -4,7 +4,7 @@ using gorilla.commons.utility;
namespace momoney.service.infrastructure.threading
{
- public interface ISynchronizedCommand : ArgCommand<Action>, ArgCommand<Command> {}
+ public interface ISynchronizedCommand : Command<Action>, Command<Command> {}
public class SynchronizedCommand : ISynchronizedCommand
{
product/client/service.infrastructure/threading/SynchronizedContext.cs
@@ -3,7 +3,7 @@ using gorilla.commons.utility;
namespace momoney.service.infrastructure.threading
{
- public interface ISynchronizationContext : ArgCommand<Command> {}
+ public interface ISynchronizationContext : Command<Command> {}
public class SynchronizedContext : ISynchronizationContext
{
product/commons/utility/ArgCommand.cs
@@ -1,7 +0,0 @@
-namespace gorilla.commons.utility
-{
- public interface ArgCommand<T>
- {
- void run_against(T item);
- }
-}
\ No newline at end of file
product/commons/utility/Callback.cs
@@ -4,7 +4,7 @@ namespace gorilla.commons.utility
{
}
- public interface Callback<T> : ArgCommand<T>
+ public interface Callback<T> : Command<T>
{
}
}
\ No newline at end of file
product/commons/utility/CallbackCommand.cs
@@ -1,6 +1,6 @@
namespace gorilla.commons.utility
{
- public interface CallbackCommand<T> : ArgCommand<Callback<T>>
+ public interface CallbackCommand<T> : Command<Callback<T>>
{
}
}
\ No newline at end of file
product/commons/utility/ChainedParameterizedCommand.cs
@@ -1,11 +1,11 @@
namespace gorilla.commons.utility
{
- public class ChainedCommand<T> : ArgCommand<T>
+ public class ChainedCommand<T> : Command<T>
{
- ArgCommand<T> left;
- ArgCommand<T> right;
+ Command<T> left;
+ Command<T> right;
- public ChainedCommand(ArgCommand<T> left, ArgCommand<T> right)
+ public ChainedCommand(Command<T> left, Command<T> right)
{
this.left = left;
this.right = right;
product/commons/utility/Command.cs
@@ -4,4 +4,9 @@ namespace gorilla.commons.utility
{
void run();
}
+
+ public interface Command<T>
+ {
+ void run_against(T item);
+ }
}
\ No newline at end of file
product/commons/utility/CommandExtensions.cs
@@ -19,7 +19,7 @@ namespace gorilla.commons.utility
return new ChainedCommand(left, new AnonymousCommand(right));
}
- static public ArgCommand<T> then<T>(this ArgCommand<T> left, ArgCommand<T> right)
+ static public Command<T> then<T>(this Command<T> left, Command<T> right)
{
return new ChainedCommand<T>(left, right);
}
product/commons/utility/utility.csproj
@@ -65,7 +65,6 @@
<Compile Include="Builder.cs" />
<Compile Include="Callback.cs" />
<Compile Include="CallbackCommand.cs" />
- <Compile Include="ArgCommand.cs" />
<Compile Include="Configuration.cs" />
<Compile Include="ComponentFactory.cs" />
<Compile Include="Id.cs" />