Commit 3f96811
Changed files (11)
trunk
product
MyMoney
Infrastructure
Presentation
Model
Menu
Presenters
Shell
Views
Utility
Core
trunk/product/MyMoney/Infrastructure/eventing/EventAggregator.cs
@@ -19,12 +19,12 @@ namespace MoMoney.Infrastructure.eventing
public class EventAggregator : IEventAggregator
{
readonly SynchronizationContext context;
- readonly List<object> subscribers;
+ readonly HashSet<object> subscribers;
readonly object mutex;
public EventAggregator(SynchronizationContext context)
{
- subscribers = new List<object>();
+ subscribers = new HashSet<object>();
mutex = new object();
this.context = context;
}
trunk/product/MyMoney/Infrastructure/Threading/AsynchronousCommandProcessor.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Linq.Expressions;
using System.Threading;
using MoMoney.Utility.Core;
@@ -19,7 +20,7 @@ namespace MoMoney.Infrastructure.Threading
manual_reset = new ManualResetEvent(false);
}
- public void add(Action action_to_process)
+ public void add(Expression<Action> action_to_process)
{
add(new ActionCommand(action_to_process));
}
trunk/product/MyMoney/Infrastructure/Threading/CommandProcessor.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Linq.Expressions;
using MoMoney.Utility.Core;
namespace MoMoney.Infrastructure.Threading
@@ -13,7 +14,7 @@ namespace MoMoney.Infrastructure.Threading
queued_commands = new Queue<ICommand>();
}
- public void add(Action action_to_process)
+ public void add(Expression<Action> action_to_process)
{
add(new ActionCommand(action_to_process));
}
@@ -25,10 +26,7 @@ namespace MoMoney.Infrastructure.Threading
public void run()
{
- while (queued_commands.Count > 0)
- {
- queued_commands.Dequeue().run();
- }
+ while (queued_commands.Count > 0) queued_commands.Dequeue().run();
}
public void stop()
trunk/product/MyMoney/Infrastructure/Threading/ICommandProcessor.cs
@@ -1,11 +1,12 @@
using System;
+using System.Linq.Expressions;
using MoMoney.Utility.Core;
namespace MoMoney.Infrastructure.Threading
{
public interface ICommandProcessor : ICommand
{
- void add(Action action_to_process);
+ void add(Expression<Action> action_to_process);
void add(ICommand command_to_process);
void stop();
}
trunk/product/MyMoney/Infrastructure/Threading/SynchronizationContextFactory.cs
@@ -1,3 +1,5 @@
+using System.Threading;
+using MoMoney.Infrastructure.Container;
using MoMoney.Utility.Core;
namespace MoMoney.Infrastructure.Threading
@@ -8,16 +10,16 @@ namespace MoMoney.Infrastructure.Threading
public class SynchronizationContextFactory : ISynchronizationContextFactory
{
- readonly ISynchronizationContext context;
+ readonly IDependencyRegistry registry;
- public SynchronizationContextFactory(ISynchronizationContext context)
+ public SynchronizationContextFactory(IDependencyRegistry registry)
{
- this.context = context;
+ this.registry = registry;
}
public ISynchronizationContext create()
{
- return context;
+ return new SynchronizedContext(registry.get_a<SynchronizationContext>());
}
}
}
\ No newline at end of file
trunk/product/MyMoney/Infrastructure/Threading/SynchronizedContext.cs
@@ -14,8 +14,8 @@ namespace MoMoney.Infrastructure.Threading
public void run(ICommand item)
{
- //context.Post(x => item.run(), new object());
- context.Send(x => { item.run(); }, new object());
+ context.Post(x => item.run(), new object());
+ //context.Send(x => item.run(), new object());
}
}
}
\ No newline at end of file
trunk/product/MyMoney/Presentation/Model/Menu/MenuItemBuilder.cs
@@ -21,10 +21,15 @@ namespace MoMoney.Presentation.Model.Menu
public class MenuItemBuilder : IMenuItemBuilder
{
readonly IDependencyRegistry registry;
- Func<bool> can_be_clicked = () => true;
readonly IEventAggregator aggregator;
readonly ICommandProcessor processor;
+ string name_of_the_menu { get; set; }
+ Action command_to_execute { get; set; }
+ HybridIcon icon { get; set; }
+ ShortcutKey key { get; set; }
+ Func<bool> can_be_clicked = () => true;
+
public MenuItemBuilder(IDependencyRegistry registry, IEventAggregator aggregator, ICommandProcessor processor)
{
name_of_the_menu = "Unknown";
@@ -36,11 +41,6 @@ namespace MoMoney.Presentation.Model.Menu
key = ShortcutKeys.none;
}
- public string name_of_the_menu { get; private set; }
- public Action command_to_execute { get; private set; }
- public HybridIcon icon { get; private set; }
- public ShortcutKey key { get; private set; }
-
public IMenuItemBuilder named(string name)
{
name_of_the_menu = name;
trunk/product/MyMoney/Presentation/Presenters/Shell/StatusBarPresenter.cs
@@ -29,10 +29,7 @@ namespace MoMoney.Presentation.Presenters.Shell
public void run()
{
- broker.subscribe_to<SavedChangesEvent>(this);
- broker.subscribe_to<NewProjectOpened>(this);
- broker.subscribe_to<ClosingTheApplication>(this);
- broker.subscribe_to<ClosingProjectEvent>(this);
+ broker.subscribe(this);
}
public void notify(SavedChangesEvent message)
trunk/product/MyMoney/Presentation/Views/Shell/ApplicationShell.cs
@@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Composition;
-using System.Drawing;
using System.Windows.Forms;
using MoMoney.Presentation.Presenters.Shell;
using MoMoney.Presentation.Views.core;
@@ -46,32 +45,25 @@ namespace MoMoney.Presentation.Views.Shell
public void add(IDockedContentView view)
{
- on_ui_thread(() => view.add_to(ux_dock_panel));
+ view.add_to(ux_dock_panel);
}
public void region<Region>(Action<Region> action) where Region : IComponent
{
ensure_that_the_region_exists<Region>();
- on_ui_thread(() => action(regions[typeof (Region).FullName].downcast_to<Region>()));
+ action(regions[typeof (Region).FullName].downcast_to<Region>());
}
public void close_the_active_window()
{
- on_ui_thread(() => ux_dock_panel.ActiveDocument.DockHandler.Close());
+ ux_dock_panel.ActiveDocument.DockHandler.Close();
}
public void close_all_windows()
{
- on_ui_thread(() =>
- {
- using (new SuspendLayout(ux_dock_panel))
- {
- while (ux_dock_panel.Contents.Count > 0)
- {
- ux_dock_panel.Contents[0].DockHandler.Close();
- }
- }
- });
+ using (new SuspendLayout(ux_dock_panel))
+ while (ux_dock_panel.Contents.Count > 0)
+ ux_dock_panel.Contents[0].DockHandler.Close();
}
void ensure_that_the_region_exists<T>()
trunk/product/MyMoney/Presentation/Views/Shell/StatusBarView.cs
@@ -14,13 +14,6 @@ namespace MoMoney.Presentation.Views.Shell
public void display(HybridIcon icon_to_display, string text_to_display)
{
- //shell.region<StatusStrip>(x =>
- // {
- // //x.Items.Clear();
- // ToolStripItem item = x.Items.Add(icon_to_display);
- // this.log().debug("icon_is:{0}", item);
- // x.Items.Add(text_to_display);
- // });
shell.region<ToolStripStatusLabel>(x =>
{
x.Text = text_to_display;
trunk/product/MyMoney/Utility/Core/ActionCommand.cs
@@ -1,4 +1,5 @@
using System;
+using System.Linq.Expressions;
namespace MoMoney.Utility.Core
{
@@ -6,6 +7,11 @@ namespace MoMoney.Utility.Core
{
readonly Action action;
+ public ActionCommand(Expression<Action> action) : this(action.Compile())
+ {
+
+ }
+
public ActionCommand(Action action)
{
this.action = action;