Commit 9a3430b
Changed files (36)
product
Boot
boot
database
transactions
Presentation
Model
product/Boot/boot/container/registration/wire_up_the_data_access_components_into_the.cs
@@ -32,7 +32,7 @@ namespace MoMoney.boot.container.registration
register.transient<IUnitOfWorkFactory, UnitOfWorkFactory>();
register.transient<ISessionFactory, SessionFactory>();
register.transient<IChangeTrackerFactory, ChangeTrackerFactory>();
- register.transient<IStatementRegistry, StatementRegistry>();
+ register.transient<DatabaseCommandRegistry, ObjectDatabaseCommandRegistry>();
register.transient<IConnectionFactory, ConnectionFactory>();
register.transient<IConfigureDatabaseStep, ConfigureDatabaseStep>();
register.transient<IConfigureObjectContainerStep, ConfigureObjectContainerStep>();
product/Boot/boot/container/registration/wire_up_the_infrastructure_in_to_the.cs
@@ -49,7 +49,7 @@ namespace MoMoney.boot.container.registration
registry.transient<ICommandPump, CommandPump>();
registry.transient<ICommandFactory, CommandFactory>();
registry.transient<ISynchronizationContextFactory, SynchronizationContextFactory>();
- registry.singleton<ICommandProcessor, AsynchronousCommandProcessor>();
+ registry.singleton<CommandProcessor, AsynchronousCommandProcessor>();
}
}
}
\ No newline at end of file
product/Boot/boot/start_the_application.cs
@@ -10,13 +10,13 @@ namespace MoMoney.boot
{
readonly IBackgroundThread thread;
readonly ILoadPresentationModulesCommand command;
- readonly ICommandProcessor processor;
+ readonly CommandProcessor processor;
public start_the_application(IBackgroundThread thread)
- : this(thread, Lazy.load<ILoadPresentationModulesCommand>(), Lazy.load<ICommandProcessor>()) {}
+ : this(thread, Lazy.load<ILoadPresentationModulesCommand>(), Lazy.load<CommandProcessor>()) {}
public start_the_application(IBackgroundThread thread, ILoadPresentationModulesCommand command,
- ICommandProcessor processor)
+ CommandProcessor processor)
{
this.thread = thread;
this.command = command;
product/Boot/Modules/Core/LoadPresentationModulesCommand.cs
@@ -7,9 +7,9 @@ namespace MoMoney.Modules.Core
public class LoadPresentationModulesCommand : ILoadPresentationModulesCommand
{
readonly Registry<IModule> registry;
- readonly ICommandProcessor processor;
+ readonly CommandProcessor processor;
- public LoadPresentationModulesCommand(Registry<IModule> registry, ICommandProcessor processor)
+ public LoadPresentationModulesCommand(Registry<IModule> registry, CommandProcessor processor)
{
this.registry = registry;
this.processor = processor;
product/Boot/Modules/Core/LoadPresentationModulesCommandSpecs.cs
@@ -15,7 +15,7 @@ namespace MoMoney.Modules.Core
context c = () =>
{
registry = the_dependency<Registry<IModule>>();
- processor = the_dependency<ICommandProcessor>();
+ processor = the_dependency<CommandProcessor>();
module = an<IModule>();
when_the(registry).is_told_to(r => r.all()).it_will_return(module);
};
@@ -24,6 +24,6 @@ namespace MoMoney.Modules.Core
static Registry<IModule> registry;
static IModule module;
- static ICommandProcessor processor;
+ static CommandProcessor processor;
}
}
\ No newline at end of file
product/database/db4o/ConnectionFactory.cs
@@ -17,11 +17,11 @@ namespace momoney.database.db4o
this.setup_container = setup_container;
}
- public IDatabaseConnection open_connection_to(File the_path_to_the_database_file)
+ public DatabaseConnection open_connection_to(File the_path_to_the_database_file)
{
var configuration = Db4oFactory.NewConfiguration();
setup.configure(configuration);
- return new DatabaseConnection(get_container(the_path_to_the_database_file, configuration));
+ return new ObjectDatabaseConnection(get_container(the_path_to_the_database_file, configuration));
}
IObjectContainer get_container(File the_path_to_the_database_file, IConfiguration configuration)
product/database/db4o/DatabaseConnection.cs โ product/database/db4o/ObjectDatabaseConnection.cs
@@ -5,11 +5,11 @@ using momoney.database.transactions;
namespace momoney.database.db4o
{
- public class DatabaseConnection : IDatabaseConnection
+ public class ObjectDatabaseConnection : DatabaseConnection
{
readonly IObjectContainer container;
- public DatabaseConnection(IObjectContainer container)
+ public ObjectDatabaseConnection(IObjectContainer container)
{
this.container = container;
}
product/database/transactions/ChangeTracker.cs
@@ -8,11 +8,11 @@ namespace momoney.database.transactions
public class ChangeTracker<T> : IChangeTracker<T> where T : Identifiable<Guid>
{
readonly ITrackerEntryMapper<T> mapper;
- readonly IStatementRegistry registry;
+ readonly DatabaseCommandRegistry registry;
readonly IList<ITrackerEntry<T>> items;
readonly IList<T> to_be_deleted;
- public ChangeTracker(ITrackerEntryMapper<T> mapper, IStatementRegistry registry)
+ public ChangeTracker(ITrackerEntryMapper<T> mapper, DatabaseCommandRegistry registry)
{
this.mapper = mapper;
this.registry = registry;
@@ -33,7 +33,7 @@ namespace momoney.database.transactions
public void commit_to(IDatabase database)
{
items.each(x => commit(x, database));
- to_be_deleted.each(x => database.apply(registry.prepare_command_for(x)));
+ to_be_deleted.each(x => database.apply(registry.prepare_for_deletion(x)));
}
public bool is_dirty()
@@ -48,7 +48,7 @@ namespace momoney.database.transactions
void commit(ITrackerEntry<T> entry, IDatabase database)
{
- if (entry.has_changes()) database.apply(registry.prepare_command_for(entry.current));
+ if (entry.has_changes()) database.apply(registry.prepare_for_flushing(entry.current));
}
}
}
\ No newline at end of file
product/database/transactions/ChangeTrackerFactory.cs
@@ -6,10 +6,10 @@ namespace momoney.database.transactions
{
public class ChangeTrackerFactory : IChangeTrackerFactory
{
- readonly IStatementRegistry statement_registry;
+ readonly DatabaseCommandRegistry statement_registry;
readonly DependencyRegistry registry;
- public ChangeTrackerFactory(IStatementRegistry statement_registry, DependencyRegistry registry)
+ public ChangeTrackerFactory(DatabaseCommandRegistry statement_registry, DependencyRegistry registry)
{
this.statement_registry = statement_registry;
this.registry = registry;
product/database/transactions/ChangeTrackerSpecs.cs
@@ -15,11 +15,11 @@ namespace momoney.database.transactions
context c = () =>
{
mapper = the_dependency<ITrackerEntryMapper<Identifiable<Guid>>>();
- registry = the_dependency<IStatementRegistry>();
+ registry = the_dependency<DatabaseCommandRegistry>();
};
static protected ITrackerEntryMapper<Identifiable<Guid>> mapper;
- static protected IStatementRegistry registry;
+ static protected DatabaseCommandRegistry registry;
}
[Concern(typeof (ChangeTracker<Identifiable<Guid>>))]
@@ -30,14 +30,14 @@ namespace momoney.database.transactions
context c = () =>
{
item = an<Identifiable<Guid>>();
- statement = an<IStatement>();
+ statement = an<DatabaseCommand>();
database = an<IDatabase>();
var entry = an<ITrackerEntry<Identifiable<Guid>>>();
when_the(mapper).is_told_to(x => x.map_from(item)).it_will_return(entry);
when_the(entry).is_told_to(x => x.has_changes()).it_will_return(true);
when_the(entry).is_told_to(x => x.current).it_will_return(item);
- when_the(registry).is_told_to(x => x.prepare_command_for(item)).it_will_return(statement);
+ when_the(registry).is_told_to(x => x.prepare_for_flushing(item)).it_will_return(statement);
};
because b = () =>
@@ -48,7 +48,7 @@ namespace momoney.database.transactions
static Identifiable<Guid> item;
static IDatabase database;
- static IStatement statement;
+ static DatabaseCommand statement;
}
[Concern(typeof (ChangeTracker<Identifiable<Guid>>))]
product/database/transactions/DatabaseCommand.cs
@@ -0,0 +1,8 @@
+using gorilla.commons.utility;
+
+namespace momoney.database.transactions
+{
+ public interface DatabaseCommand : ParameterizedCommand<DatabaseConnection>
+ {
+ }
+}
\ No newline at end of file
product/database/transactions/DatabaseCommandRegistry.cs
@@ -0,0 +1,11 @@
+using System;
+using gorilla.commons.utility;
+
+namespace momoney.database.transactions
+{
+ public interface DatabaseCommandRegistry
+ {
+ DatabaseCommand prepare_for_deletion<T>(T entity) where T : Identifiable<Guid>;
+ DatabaseCommand prepare_for_flushing<T>(T entity) where T : Identifiable<Guid>;
+ }
+}
\ No newline at end of file
product/database/transactions/IDatabaseConnection.cs โ product/database/transactions/DatabaseConnection.cs
@@ -3,7 +3,7 @@ using System.Collections.Generic;
namespace momoney.database.transactions
{
- public interface IDatabaseConnection : IDisposable
+ public interface DatabaseConnection : IDisposable
{
IEnumerable<T> query<T>();
IEnumerable<T> query<T>(Predicate<T> predicate);
product/database/transactions/DeleteFromDatabase.cs
@@ -0,0 +1,17 @@
+namespace momoney.database.transactions
+{
+ public class DeleteFromDatabase<T> : DatabaseCommand
+ {
+ readonly T entity;
+
+ public DeleteFromDatabase(T entity)
+ {
+ this.entity = entity;
+ }
+
+ public void run(DatabaseConnection connection)
+ {
+ connection.delete(entity);
+ }
+ }
+}
\ No newline at end of file
product/database/transactions/IDatabase.cs
@@ -7,6 +7,6 @@ namespace momoney.database.transactions
public interface IDatabase
{
IEnumerable<T> fetch_all<T>() where T : Identifiable<Guid>;
- void apply(IStatement statement);
+ void apply(DatabaseCommand command);
}
}
\ No newline at end of file
product/database/transactions/IStatement.cs
@@ -1,7 +0,0 @@
-namespace momoney.database.transactions
-{
- public interface IStatement
- {
- void prepare(IDatabaseConnection connection);
- }
-}
\ No newline at end of file
product/database/transactions/IStatementRegistry.cs
@@ -1,11 +0,0 @@
-using System;
-using gorilla.commons.utility;
-
-namespace momoney.database.transactions
-{
- public interface IStatementRegistry
- {
- IStatement prepare_delete_statement_for<T>(T entity) where T : Identifiable<Guid>;
- IStatement prepare_command_for<T>(T entity) where T : Identifiable<Guid>;
- }
-}
\ No newline at end of file
product/database/transactions/ObjectDatabaseCommandRegistry.cs
@@ -0,0 +1,18 @@
+using System;
+using gorilla.commons.utility;
+
+namespace momoney.database.transactions
+{
+ public class ObjectDatabaseCommandRegistry : DatabaseCommandRegistry
+ {
+ public DatabaseCommand prepare_for_deletion<T>(T entity) where T : Identifiable<Guid>
+ {
+ return new DeleteFromDatabase<T>(entity);
+ }
+
+ public DatabaseCommand prepare_for_flushing<T>(T entity) where T : Identifiable<Guid>
+ {
+ return new SaveOrUpdateFromDatabase<T>(entity);
+ }
+ }
+}
\ No newline at end of file
product/database/transactions/SaveOrUpdateFromDatabase.cs
@@ -0,0 +1,20 @@
+using System;
+using gorilla.commons.utility;
+
+namespace momoney.database.transactions
+{
+ public class SaveOrUpdateFromDatabase<T> : DatabaseCommand where T : Identifiable<Guid>
+ {
+ readonly T entity;
+
+ public SaveOrUpdateFromDatabase(T entity)
+ {
+ this.entity = entity;
+ }
+
+ public void run(DatabaseConnection connection)
+ {
+ connection.store(entity);
+ }
+ }
+}
\ No newline at end of file
product/database/transactions/StatementRegistry.cs
@@ -1,48 +0,0 @@
-using System;
-using gorilla.commons.utility;
-
-namespace momoney.database.transactions
-{
- public class StatementRegistry : IStatementRegistry
- {
- public IStatement prepare_delete_statement_for<T>(T entity) where T : Identifiable<Guid>
- {
- return new DeletionStatement<T>(entity);
- }
-
- public IStatement prepare_command_for<T>(T entity) where T : Identifiable<Guid>
- {
- return new SaveOrUpdateStatement<T>(entity);
- }
- }
-
- public class SaveOrUpdateStatement<T> : IStatement where T : Identifiable<Guid>
- {
- readonly T entity;
-
- public SaveOrUpdateStatement(T entity)
- {
- this.entity = entity;
- }
-
- public void prepare(IDatabaseConnection connection)
- {
- connection.store(entity);
- }
- }
-
- public class DeletionStatement<T> : IStatement
- {
- readonly T entity;
-
- public DeletionStatement(T entity)
- {
- this.entity = entity;
- }
-
- public void prepare(IDatabaseConnection connection)
- {
- connection.delete(entity);
- }
- }
-}
\ No newline at end of file
product/database/database.csproj
@@ -90,7 +90,7 @@
<Compile Include="db4o\ConfigureDatabaseStep.cs" />
<Compile Include="db4o\ConnectionFactory.cs" />
<Compile Include="ObjectDatabase.cs" />
- <Compile Include="db4o\DatabaseConnection.cs" />
+ <Compile Include="db4o\ObjectDatabaseConnection.cs" />
<Compile Include="IConnectionFactory.cs" />
<Compile Include="IDatabaseConfiguration.cs" />
<Compile Include="transactions\ChangeTracker.cs" />
@@ -101,22 +101,24 @@
<Compile Include="transactions\ContextFactory.cs" />
<Compile Include="transactions\ContextFactorySpecs.cs" />
<Compile Include="transactions\CurrentThread.cs" />
+ <Compile Include="transactions\DeleteFromDatabase.cs" />
<Compile Include="transactions\IChangeTracker.cs" />
<Compile Include="transactions\IChangeTrackerFactory.cs" />
<Compile Include="transactions\IContext.cs" />
<Compile Include="transactions\IDatabase.cs" />
- <Compile Include="transactions\IDatabaseConnection.cs" />
+ <Compile Include="transactions\DatabaseConnection.cs" />
<Compile Include="transactions\IdentityMapProxy.cs" />
<Compile Include="transactions\IdentityMapSpecs.cs" />
<Compile Include="transactions\IIdentityMap.cs" />
<Compile Include="transactions\IKey.cs" />
<Compile Include="transactions\IScopedStorage.cs" />
- <Compile Include="transactions\IStatement.cs" />
- <Compile Include="transactions\IStatementRegistry.cs" />
+ <Compile Include="transactions\DatabaseCommand.cs" />
+ <Compile Include="transactions\DatabaseCommandRegistry.cs" />
<Compile Include="transactions\IThread.cs" />
<Compile Include="transactions\PerThread.cs" />
<Compile Include="transactions\PerThreadScopedStorage.cs" />
<Compile Include="transactions\PerThreadScopedStorageSpecs.cs" />
+ <Compile Include="transactions\SaveOrUpdateFromDatabase.cs" />
<Compile Include="transactions\Session.cs" />
<Compile Include="transactions\SessionFactory.cs" />
<Compile Include="transactions\SessionFactorySpecs.cs" />
@@ -124,7 +126,7 @@
<Compile Include="transactions\SessionProvider.cs" />
<Compile Include="transactions\SessionSpecs.cs" />
<Compile Include="transactions\SingletonScopedStorage.cs" />
- <Compile Include="transactions\StatementRegistry.cs" />
+ <Compile Include="transactions\ObjectDatabaseCommandRegistry.cs" />
<Compile Include="transactions\TrackerEntry.cs" />
<Compile Include="transactions\TrackerEntryMapper.cs" />
<Compile Include="transactions\TrackerEntrySpecs.cs" />
product/database/IConnectionFactory.cs
@@ -5,6 +5,6 @@ namespace momoney.database
{
public interface IConnectionFactory
{
- IDatabaseConnection open_connection_to(File the_path_to_the_database_file);
+ DatabaseConnection open_connection_to(File the_path_to_the_database_file);
}
}
\ No newline at end of file
product/database/ObjectDatabase.cs
@@ -28,11 +28,11 @@ namespace momoney.database
}
}
- public void apply(IStatement statement)
+ public void apply(DatabaseCommand command)
{
using (var connection = factory.open_connection_to(path_to_database()))
{
- statement.prepare(connection);
+ command.run(connection);
connection.commit();
}
}
product/Presentation/Core/ApplicationEnvironment.cs
@@ -11,9 +11,9 @@ namespace MoMoney.Presentation.Core
public class ApplicationEnvironment : IApplication
{
- readonly ICommandProcessor processor;
+ readonly CommandProcessor processor;
- public ApplicationEnvironment(ICommandProcessor processor)
+ public ApplicationEnvironment(CommandProcessor processor)
{
this.processor = processor;
}
product/Presentation/Model/Menu/MenuItemBuilder.cs
@@ -22,7 +22,7 @@ namespace MoMoney.Presentation.Model.Menu
{
readonly DependencyRegistry registry;
readonly IEventAggregator aggregator;
- readonly ICommandProcessor processor;
+ readonly CommandProcessor processor;
string name_of_the_menu { get; set; }
Action command_to_execute { get; set; }
@@ -30,7 +30,7 @@ namespace MoMoney.Presentation.Model.Menu
ShortcutKey key { get; set; }
Func<bool> can_be_clicked = () => true;
- public MenuItemBuilder(DependencyRegistry registry, IEventAggregator aggregator, ICommandProcessor processor)
+ public MenuItemBuilder(DependencyRegistry registry, IEventAggregator aggregator, CommandProcessor processor)
{
name_of_the_menu = "Unknown";
command_to_execute = () => {};
product/Presentation/Model/Menu/ToolBarItemBuilder.cs
@@ -11,10 +11,10 @@ namespace MoMoney.Presentation.Model.Menu
{
readonly DependencyRegistry registry;
readonly ToolStripButton item;
- readonly ICommandProcessor processor;
+ readonly CommandProcessor processor;
Func<bool> the_condition;
- public ToolBarItemBuilder(DependencyRegistry registry, IEventAggregator aggregator, ICommandProcessor processor)
+ public ToolBarItemBuilder(DependencyRegistry registry, IEventAggregator aggregator, CommandProcessor processor)
{
this.registry = registry;
this.processor = processor;
product/Presentation/Presenters/CommandPump.cs
@@ -7,19 +7,17 @@ namespace MoMoney.Presentation.Presenters
public interface ICommandPump
{
ICommandPump run<Command>() where Command : gorilla.commons.utility.Command;
- ICommandPump run<Command>(Command command) where Command : gorilla.commons.utility.Command;
ICommandPump run<Command, T>(T input) where Command : ParameterizedCommand<T>;
- ICommandPump run<T>(Callback<T> item, Query<T> query);
ICommandPump run<Output, Query>(Callback<Output> item) where Query : Query<Output>;
}
public class CommandPump : ICommandPump
{
- readonly ICommandProcessor processor;
+ readonly CommandProcessor processor;
readonly DependencyRegistry registry;
readonly ICommandFactory factory;
- public CommandPump(ICommandProcessor processor, DependencyRegistry registry, ICommandFactory factory)
+ public CommandPump(CommandProcessor processor, DependencyRegistry registry, ICommandFactory factory)
{
this.processor = processor;
this.factory = factory;
product/Presentation/Presenters/RunPresenterCommand.cs
@@ -6,9 +6,9 @@ namespace MoMoney.Presentation.Presenters
public class RunPresenterCommand : IRunPresenterCommand
{
readonly IApplicationController application_controller;
- readonly ICommandProcessor processor;
+ readonly CommandProcessor processor;
- public RunPresenterCommand(IApplicationController application_controller, ICommandProcessor processor)
+ public RunPresenterCommand(IApplicationController application_controller, CommandProcessor processor)
{
this.application_controller = application_controller;
this.processor = processor;
product/Presentation/Presenters/RunThe.cs
@@ -9,9 +9,9 @@ namespace momoney.presentation.presenters
public class RunThe<TPresenter> : IRunThe<TPresenter> where TPresenter : IPresenter
{
readonly IApplicationController controller;
- readonly ICommandProcessor processor;
+ readonly CommandProcessor processor;
- public RunThe(IApplicationController controller, ICommandProcessor processor)
+ public RunThe(IApplicationController controller, CommandProcessor processor)
{
this.controller = controller;
this.processor = processor;
product/Presentation/Presenters/RunTheSpecs.cs
@@ -19,13 +19,13 @@ namespace momoney.presentation.presenters
context c = () =>
{
controller = the_dependency<IApplicationController>();
- processor = the_dependency<ICommandProcessor>();
+ processor = the_dependency<CommandProcessor>();
};
because b = () => sut.run();
static IApplicationController controller;
- static ICommandProcessor processor;
+ static CommandProcessor processor;
}
}
}
\ No newline at end of file
product/service.infrastructure/threading/AsynchronousCommandProcessor.cs
@@ -6,7 +6,7 @@ using gorilla.commons.utility;
namespace MoMoney.Service.Infrastructure.Threading
{
- public class AsynchronousCommandProcessor : ICommandProcessor
+ public class AsynchronousCommandProcessor : CommandProcessor
{
readonly Queue<Command> queued_commands;
readonly EventWaitHandle manual_reset;
product/service.infrastructure/threading/CommandProcessor.cs
@@ -1,37 +1,13 @@
using System;
-using System.Collections.Generic;
using System.Linq.Expressions;
using gorilla.commons.utility;
namespace MoMoney.Service.Infrastructure.Threading
{
- public class CommandProcessor : ICommandProcessor
+ public interface CommandProcessor : Command
{
- readonly Queue<Command> queued_commands;
-
- public CommandProcessor()
- {
- queued_commands = new Queue<Command>();
- }
-
- public void add(Expression<Action> action_to_process)
- {
- add(new AnonymousCommand(action_to_process));
- }
-
- public void add(Command command_to_process)
- {
- queued_commands.Enqueue(command_to_process);
- }
-
- public void run()
- {
- while (queued_commands.Count > 0) queued_commands.Dequeue().run();
- }
-
- public void stop()
- {
- queued_commands.Clear();
- }
+ void add(Expression<Action> action_to_process);
+ void add(Command command_to_process);
+ void stop();
}
}
\ No newline at end of file
product/service.infrastructure/threading/CommandProcessorSpecs.cs
@@ -5,10 +5,10 @@ using MoMoney.Service.Infrastructure.Threading;
namespace momoney.service.infrastructure.threading
{
- [Concern(typeof (CommandProcessor))]
- public abstract class behaves_like_a_command_processor : concerns_for<ICommandProcessor, CommandProcessor> {}
+ [Concern(typeof (SynchronousCommandProcessor))]
+ public abstract class behaves_like_a_command_processor : concerns_for<CommandProcessor, SynchronousCommandProcessor> {}
- [Concern(typeof (CommandProcessor))]
+ [Concern(typeof (SynchronousCommandProcessor))]
public class when_running_all_the_queued_commands_waiting_for_execution : behaves_like_a_command_processor
{
it should_run_the_first_command_in_the_queue = () => first_command.was_told_to(f => f.run());
@@ -32,7 +32,7 @@ namespace momoney.service.infrastructure.threading
static Command second_command;
}
- [Concern(typeof (CommandProcessor))]
+ [Concern(typeof (SynchronousCommandProcessor))]
public class when_attempting_to_rerun_the_command_processor : behaves_like_a_command_processor
{
it should_not_re_run_the_commands_that_have_already_executed =
product/service.infrastructure/threading/ICommandProcessor.cs
@@ -1,13 +0,0 @@
-using System;
-using System.Linq.Expressions;
-using gorilla.commons.utility;
-
-namespace MoMoney.Service.Infrastructure.Threading
-{
- public interface ICommandProcessor : Command
- {
- void add(Expression<Action> action_to_process);
- void add(Command command_to_process);
- void stop();
- }
-}
\ No newline at end of file
product/service.infrastructure/threading/SynchronousCommandProcessor.cs
@@ -0,0 +1,37 @@
+using System;
+using System.Collections.Generic;
+using System.Linq.Expressions;
+using gorilla.commons.utility;
+
+namespace MoMoney.Service.Infrastructure.Threading
+{
+ public class SynchronousCommandProcessor : CommandProcessor
+ {
+ readonly Queue<Command> queued_commands;
+
+ public SynchronousCommandProcessor()
+ {
+ queued_commands = new Queue<Command>();
+ }
+
+ public void add(Expression<Action> action_to_process)
+ {
+ add(new AnonymousCommand(action_to_process));
+ }
+
+ public void add(Command command_to_process)
+ {
+ queued_commands.Enqueue(command_to_process);
+ }
+
+ public void run()
+ {
+ while (queued_commands.Count > 0) queued_commands.Dequeue().run();
+ }
+
+ public void stop()
+ {
+ queued_commands.Clear();
+ }
+ }
+}
\ No newline at end of file
product/service.infrastructure/service.infrastructure.csproj
@@ -101,9 +101,9 @@
<Compile Include="threading\BackgroundThreadFactory.cs" />
<Compile Include="threading\BackgroundThreadFactorySpecs.cs" />
<Compile Include="threading\BackgroundThreadSpecs.cs" />
- <Compile Include="threading\CommandProcessor.cs" />
+ <Compile Include="threading\SynchronousCommandProcessor.cs" />
<Compile Include="threading\CommandProcessorSpecs.cs" />
- <Compile Include="threading\ICommandProcessor.cs" />
+ <Compile Include="threading\CommandProcessor.cs" />
<Compile Include="threading\IntervalTimer.cs" />
<Compile Include="threading\IntervalTimerSpecs.cs" />
<Compile Include="threading\ITimerClient.cs" />