Commit 5f0a309
Changed files (14)
trunk
product
MyMoney
boot
container
Infrastructure
Container
Presentation
Presenters
Menu
Views
trunk/product/MyMoney/boot/container/registration/wire_up_the_essential_services_into_the.cs
@@ -20,7 +20,6 @@ namespace MoMoney.boot.container.registration
{
registration.singleton<IDependencyRegistration>(registration);
registration.singleton<ILogFactory, Log4NetLogFactory>();
- registration.singleton<ISynchronizationContext>(new SynchronizedContext(SynchronizationContext.Current));
}
}
}
\ No newline at end of file
trunk/product/MyMoney/boot/container/registration/wire_up_the_views_in_to_the.cs
@@ -1,4 +1,5 @@
using System.ComponentModel;
+using System.Threading;
using MoMoney.Infrastructure.Container.Windsor;
using MoMoney.Infrastructure.interceptors;
using MoMoney.Infrastructure.proxies;
@@ -28,8 +29,9 @@ namespace MoMoney.boot.container.registration
public void run()
{
var shell = new ApplicationShell();
- register.singleton<IShell>(shell);
- //register.proxy<IShell>(new SynchronizedConfiguration<IShell>(), () => shell);
+ register.singleton<ISynchronizationContext>(new SynchronizedContext(SynchronizationContext.Current));
+ //register.singleton<IShell>(shell);
+ register.proxy(new SynchronizedConfiguration<IShell>(), () => shell);
register.singleton(shell);
//register.proxy(new SynchronizedViewProxyConfiguration<IShell>(), () => new ApplicationShell());
register.transient<IAboutApplicationView, AboutTheApplicationView>();
@@ -63,7 +65,10 @@ namespace MoMoney.boot.container.registration
{
public void configure(IProxyBuilder<T> item)
{
- item.add_interceptor<IThreadSafeInterceptor>( new ThreadSafeInterceptor(Lazy.load<ISynchronizationContextFactory>())).InterceptAll();
+ item
+ .add_interceptor<IThreadSafeInterceptor>(
+ new ThreadSafeInterceptor(Lazy.load<ISynchronizationContextFactory>()))
+ .InterceptAll();
}
}
}
\ No newline at end of file
trunk/product/MyMoney/boot/container/wire_up_the_container.cs
@@ -19,8 +19,8 @@ namespace MoMoney.boot.container
var specification = new ComponentExclusionSpecification();
var configuration = new ComponentRegistrationConfiguration();
- new wire_up_the_essential_services_into_the(registry)
- .then(new auto_wire_components_in_to_the(registry, specification))
+ new auto_wire_components_in_to_the(registry, specification)
+ .then(new wire_up_the_essential_services_into_the(registry))
.then(new wire_up_the_data_access_components_into_the(registry))
.then(new wire_up_the_infrastructure_in_to_the(registry))
.then(new wire_up_the_mappers_in_to_the(registry))
trunk/product/MyMoney/Infrastructure/Container/Autofac/AutofacDependencyRegistry.cs
@@ -1,13 +1,6 @@
using System;
using System.Collections.Generic;
using Autofac;
-using Autofac.Builder;
-using Autofac.Modules;
-using AutofacContrib.DynamicProxy2;
-using MoMoney.Infrastructure.Container.Windsor;
-using MoMoney.Infrastructure.proxies;
-using MoMoney.Utility.Core;
-using MoMoney.Utility.Extensions;
namespace MoMoney.Infrastructure.Container.Autofac
{
@@ -30,59 +23,4 @@ namespace MoMoney.Infrastructure.Container.Autofac
return container().Resolve<IEnumerable<Interface>>();
}
}
-
- internal class AutofacDependencyRegistryBuilder : IDependencyRegistration, IBuilder<IContainer>
- {
- readonly ContainerBuilder builder;
-
- public AutofacDependencyRegistryBuilder() : this(new ContainerBuilder())
- {
- }
-
- public AutofacDependencyRegistryBuilder(ContainerBuilder builder)
- {
- this.builder = builder;
- builder.RegisterModule(new ImplicitCollectionSupportModule());
- builder.RegisterModule(new StandardInterceptionModule());
- }
-
- public void singleton<Contract, Implementation>() where Implementation : Contract
- {
- builder.Register<Implementation>().As<Contract>().SingletonScoped();
- }
-
- public void singleton<Contract>(Contract instance_of_the_contract)
- {
- builder.Register(instance_of_the_contract).As<Contract>().SingletonScoped();
- }
-
- public void transient<Contract, Implementation>() where Implementation : Contract
- {
- transient(typeof (Contract), typeof (Implementation));
- }
-
- public void transient(Type contract, Type implementation)
- {
- if (contract.is_a_generic_type())
- {
- builder.RegisterGeneric(implementation).As(contract).FactoryScoped();
- }
- else
- {
- builder.Register(implementation).As(contract).FactoryScoped();
- }
- }
-
- public void proxy<T>(IConfiguration<IProxyBuilder<T>> configuration, Func<T> target)
- {
- var proxy_builder = new ProxyBuilder<T>();
- configuration.configure(proxy_builder);
- builder.Register(x => proxy_builder.create_proxy_for(target)).As<T>().FactoryScoped();
- }
-
- public IContainer build()
- {
- return builder.Build();
- }
- }
}
\ No newline at end of file
trunk/product/MyMoney/Infrastructure/Container/Autofac/AutofacDependencyRegistryBuilder.cs
@@ -0,0 +1,67 @@
+using System;
+using Autofac;
+using Autofac.Builder;
+using Autofac.Modules;
+using AutofacContrib.DynamicProxy2;
+using MoMoney.Infrastructure.Container.Windsor;
+using MoMoney.Infrastructure.proxies;
+using MoMoney.Utility.Core;
+using MoMoney.Utility.Extensions;
+
+namespace MoMoney.Infrastructure.Container.Autofac
+{
+ internal class AutofacDependencyRegistryBuilder : IDependencyRegistration, IBuilder<IContainer>
+ {
+ readonly ContainerBuilder builder;
+
+ public AutofacDependencyRegistryBuilder() : this(new ContainerBuilder())
+ {
+ }
+
+ public AutofacDependencyRegistryBuilder(ContainerBuilder builder)
+ {
+ this.builder = builder;
+ builder.RegisterModule(new ImplicitCollectionSupportModule());
+ builder.RegisterModule(new StandardInterceptionModule());
+ }
+
+ public void singleton<Contract, Implementation>() where Implementation : Contract
+ {
+ builder.Register<Implementation>().As<Contract>().SingletonScoped();
+ }
+
+ public void singleton<Contract>(Contract instance_of_the_contract)
+ {
+ builder.Register(instance_of_the_contract).As<Contract>().SingletonScoped();
+ }
+
+ public void transient<Contract, Implementation>() where Implementation : Contract
+ {
+ transient(typeof (Contract), typeof (Implementation));
+ }
+
+ public void transient(Type contract, Type implementation)
+ {
+ if (contract.is_a_generic_type())
+ {
+ builder.RegisterGeneric(implementation).As(contract).FactoryScoped();
+ }
+ else
+ {
+ builder.Register(implementation).As(contract).FactoryScoped();
+ }
+ }
+
+ public void proxy<T>(IConfiguration<IProxyBuilder<T>> configuration, Func<T> target)
+ {
+ var proxy_builder = new ProxyBuilder<T>();
+ configuration.configure(proxy_builder);
+ builder.Register(x => proxy_builder.create_proxy_for(target)).As<T>().FactoryScoped();
+ }
+
+ public IContainer build()
+ {
+ return builder.Build();
+ }
+ }
+}
\ No newline at end of file
trunk/product/MyMoney/Infrastructure/proxies/IInterceptorConstraint.cs
@@ -1,4 +1,5 @@
using System.Collections.Generic;
+using System.ComponentModel;
using System.Linq;
using System.Reflection;
using MoMoney.Infrastructure.Extensions;
@@ -31,7 +32,16 @@ namespace MoMoney.Infrastructure.proxies
var methods = typeof (TypeToPutConstraintOn).GetMethods(BindingFlags.Public | BindingFlags.Instance);
foreach (var method in methods)
{
- method.Invoke(InterceptOn, get_stub_parameters_for(method).ToArray());
+ if (method.ContainsGenericParameters)
+ {
+ method
+ .MakeGenericMethod(typeof(Component))
+ .Invoke(InterceptOn, get_stub_parameters_for(method).ToArray());
+ }
+ else
+ {
+ method.Invoke(InterceptOn, get_stub_parameters_for(method).ToArray());
+ }
}
}
trunk/product/MyMoney/Infrastructure/proxies/ProxyBuilderSpecs.cs
@@ -1,3 +1,4 @@
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
@@ -90,9 +91,10 @@ namespace MoMoney.Infrastructure.proxies
it should_intercept_each_call =
() =>
{
- SomeInterceptor.MethodsCalled.Count().should_be_equal_to(2);
+ SomeInterceptor.MethodsCalled.Count().should_be_equal_to(3 );
SomeInterceptor.MethodsCalled.First().Name.should_be_equal_to("OneMethod");
- SomeInterceptor.MethodsCalled.Skip(1).First().Name.should_be_equal_to( "SecondMethod");
+ SomeInterceptor.MethodsCalled.Skip(1).First().Name.should_be_equal_to("SecondMethod");
+ SomeInterceptor.MethodsCalled.Skip(2).First().Name.should_be_equal_to("region");
};
context c = () => { an_implementation = an<IAnInterface>(); };
@@ -105,6 +107,7 @@ namespace MoMoney.Infrastructure.proxies
var proxy = sut.create_proxy_for(() => an_implementation);
proxy.OneMethod();
proxy.SecondMethod();
+ proxy.region(() => "mo");
};
after_each_observation ae = () =>
@@ -123,12 +126,13 @@ namespace MoMoney.Infrastructure.proxies
void SecondMethod();
int FirstValueReturningMethod();
int ValueReturningMethodWithAnArgument(int number);
+ void region<T>(Func<T> call);
}
public class SomeInterceptor : IInterceptor
{
- static public bool WasCalled;
- static public IList<MethodInfo> MethodsCalled;
+ public static bool WasCalled;
+ public static IList<MethodInfo> MethodsCalled;
static SomeInterceptor()
{
@@ -142,7 +146,7 @@ namespace MoMoney.Infrastructure.proxies
invocation.Proceed();
}
- static public void Cleanup()
+ public static void Cleanup()
{
WasCalled = false;
MethodsCalled.Clear();
@@ -151,8 +155,8 @@ namespace MoMoney.Infrastructure.proxies
public class AnotherInterceptor : IInterceptor
{
- static public bool WasCalled;
- static public IList<MethodInfo> MethodsCalled;
+ public static bool WasCalled;
+ public static IList<MethodInfo> MethodsCalled;
static AnotherInterceptor()
{
@@ -166,7 +170,7 @@ namespace MoMoney.Infrastructure.proxies
invocation.Proceed();
}
- static public void Cleanup()
+ public static void Cleanup()
{
WasCalled = false;
MethodsCalled.Clear();
@@ -194,5 +198,9 @@ namespace MoMoney.Infrastructure.proxies
{
return number + 1;
}
+
+ public void region<T>(Func<T> call)
+ {
+ }
}
}
\ No newline at end of file
trunk/product/MyMoney/Infrastructure/Threading/ISynchronizationContext.cs
@@ -0,0 +1,8 @@
+using MoMoney.Utility.Core;
+
+namespace MoMoney.Infrastructure.Threading
+{
+ public interface ISynchronizationContext : IParameterizedCommand<ICommand>
+ {
+ }
+}
\ No newline at end of file
trunk/product/MyMoney/Infrastructure/Threading/SynchronizationContext.cs → trunk/product/MyMoney/Infrastructure/Threading/SynchronizedContext.cs
@@ -1,19 +1,20 @@
+using System;
using System.Threading;
using MoMoney.Utility.Core;
namespace MoMoney.Infrastructure.Threading
{
- public interface ISynchronizationContext : IParameterizedCommand<ICommand>
- {
- }
-
public class SynchronizedContext : ISynchronizationContext
{
readonly SynchronizationContext context;
public SynchronizedContext(SynchronizationContext context)
{
- this.context = context;
+ if (context != null) this.context = context;
+ else
+ {
+ throw new ArgumentNullException();
+ }
}
public void run(ICommand item)
trunk/product/MyMoney/Presentation/Presenters/Menu/Help/AboutTheApplicationPresenter.cs
@@ -1,3 +1,4 @@
+using MoMoney.Infrastructure.Extensions;
using MoMoney.Presentation.Core;
using MoMoney.Presentation.Views.Menu.Help;
@@ -9,7 +10,7 @@ namespace MoMoney.Presentation.Presenters.Menu.Help
public class AboutTheApplicationPresenter : IAboutApplicationPresenter
{
- private readonly IAboutApplicationView view;
+ readonly IAboutApplicationView view;
public AboutTheApplicationPresenter(IAboutApplicationView view)
{
@@ -18,6 +19,7 @@ namespace MoMoney.Presentation.Presenters.Menu.Help
public void run()
{
+ this.log().debug("about app");
view.display();
}
}
trunk/product/MyMoney/Presentation/Views/Shell/ApplicationShell.cs
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Composition;
+using System.Windows.Forms;
using MoMoney.Presentation.Presenters.Shell;
using MoMoney.Presentation.Views.core;
using MoMoney.Utility.Extensions;
@@ -19,6 +20,7 @@ namespace MoMoney.Presentation.Views.Shell
regions = new Dictionary<string, IComponent>
{
{GetType().FullName, this},
+ {typeof(Form).FullName, this},
{ux_main_menu_strip.GetType().FullName, ux_main_menu_strip},
{ux_dock_panel.GetType().FullName, ux_dock_panel},
{ux_tool_bar_strip.GetType().FullName, ux_tool_bar_strip},
trunk/product/MyMoney/Presentation/Views/Shell/IShell.cs
@@ -9,7 +9,6 @@ namespace MoMoney.Presentation.Views.Shell
public interface IShell : IWin32Window, ISynchronizeInvoke, IContainerControl, IBindableComponent, IDropTarget
{
void attach_to(IApplicationShellPresenter presenter);
- string Text { get; set; }
void add(IDockedContentView view);
void region<T>(Action<T> action) where T : IComponent;
void close_the_active_window();
trunk/product/MyMoney/Presentation/Views/Shell/TitleBar.cs
@@ -1,3 +1,5 @@
+using System.Windows.Forms;
+
namespace MoMoney.Presentation.Views.Shell
{
public interface ITitleBar
@@ -18,25 +20,34 @@ namespace MoMoney.Presentation.Views.Shell
public void display(string title)
{
- if (shell.Text.Contains("-"))
+ shell.region<Form>(x =>
{
- shell.Text = shell.Text.Remove(shell.Text.IndexOf("-") - 1);
- }
- shell.Text = shell.Text + " - " + title;
+ if (x.Text.Contains("-"))
+ {
+ x.Text =x.Text.Remove(x.Text.IndexOf("-") - 1);
+ }
+ x.Text =x.Text + " - " + title;
+ });
}
public void append_asterik()
{
- if (shell.Text.Contains("*"))
+ shell.region<Form>(x =>
{
- return;
- }
- shell.Text = shell.Text + "*";
+ if (x.Text.Contains("*"))
+ {
+ return;
+ }
+ x.Text = x.Text + "*";
+ });
}
public void remove_asterik()
{
- shell.Text = shell.Text.Replace("*", "");
+ shell.region<Form>(x =>
+ {
+ x.Text = x.Text.Replace("*", "");
+ });
}
}
}
\ No newline at end of file
trunk/product/MyMoney/MyMoney.csproj
@@ -217,6 +217,7 @@
<Compile Include="Infrastructure\cloning\Prototype.cs" />
<Compile Include="Infrastructure\cloning\Serializer.cs" />
<Compile Include="Infrastructure\Container\Autofac\AutofacDependencyRegistry.cs" />
+ <Compile Include="Infrastructure\Container\Autofac\AutofacDependencyRegistryBuilder.cs" />
<Compile Include="Infrastructure\Container\Autofac\AutofacSpecs.cs" />
<Compile Include="Infrastructure\Container\Windsor\configuration\ApplyLoggingInterceptor.cs" />
<Compile Include="Infrastructure\Container\Windsor\configuration\ComponentExclusionSpecification.cs" />
@@ -280,10 +281,11 @@
<Compile Include="Infrastructure\Threading\BackgroundThread.cs">
</Compile>
<Compile Include="Infrastructure\Threading\IntervalTimer.cs" />
+ <Compile Include="Infrastructure\Threading\ISynchronizationContext.cs" />
<Compile Include="Infrastructure\Threading\Juval\Synchronizer.cs" />
<Compile Include="Infrastructure\Threading\Juval\WorkItem.cs" />
- <Compile Include="Infrastructure\Threading\SynchronizationContext.cs" />
<Compile Include="Infrastructure\Threading\SynchronizationContextFactory.cs" />
+ <Compile Include="Infrastructure\Threading\SynchronizedContext.cs" />
<Compile Include="Infrastructure\Threading\ThreadSafeInterceptor.cs" />
<Compile Include="Infrastructure\Threading\TimerFactory.cs" />
<Compile Include="Infrastructure\Threading\WorkerThread.cs">