Commit b19f19d
Changed files (18)
trunk
product
MyMoney
boot
Infrastructure
Presentation
Presenters
Navigation
Views
Navigation
trunk/product/MyMoney/boot/container/registration/SynchronizedConfiguration.cs
@@ -0,0 +1,14 @@
+using MoMoney.Infrastructure.proxies;
+using MoMoney.Infrastructure.Threading;
+using MoMoney.Utility.Core;
+
+namespace MoMoney.boot.container.registration
+{
+ internal class SynchronizedConfiguration<T> : IConfiguration<IProxyBuilder<T>>
+ {
+ public void configure(IProxyBuilder<T> item)
+ {
+ item.add_interceptor<ThreadSafeInterceptor>().intercept_all();
+ }
+ }
+}
\ No newline at end of file
trunk/product/MyMoney/boot/container/registration/wire_up_the_essential_services_into_the.cs
@@ -1,3 +1,5 @@
+using System.Threading;
+using System.Windows.Forms;
using MoMoney.Infrastructure.Container;
using MoMoney.Infrastructure.Logging;
using MoMoney.Infrastructure.Logging.Log4NetLogging;
@@ -21,6 +23,15 @@ namespace MoMoney.boot.container.registration
registration.singleton<IDependencyRegistry>(() => registration.build());
registration.singleton<ILogFactory, Log4NetLogFactory>();
registration.singleton<ICommandProcessor, AsynchronousCommandProcessor>();
+ registration.singleton(
+ () =>
+ {
+ if (SynchronizationContext.Current == null)
+ {
+ SynchronizationContext.SetSynchronizationContext(new WindowsFormsSynchronizationContext());
+ }
+ return SynchronizationContext.Current;
+ });
}
}
}
\ No newline at end of file
trunk/product/MyMoney/boot/container/registration/wire_up_the_presentation_modules.cs
@@ -6,6 +6,7 @@ using MoMoney.Presentation.Model.Menu.File;
using MoMoney.Presentation.Model.Menu.Help;
using MoMoney.Presentation.Model.Menu.window;
using MoMoney.Presentation.Presenters.Commands;
+using MoMoney.Presentation.Views.Shell;
using MoMoney.Utility.Core;
using MoMoney.Utility.Extensions;
@@ -27,6 +28,9 @@ namespace MoMoney.boot.container.registration
public void run(IAssembly item)
{
+ registry.proxy<IApplicationController, SynchronizedConfiguration<IApplicationController>>(
+ () =>
+ new ApplicationController(resolve.dependency_for<IPresenterRegistry>(), resolve.dependency_for<IShell>()));
registry.transient(typeof (IRunThe<>), typeof (RunThe<>));
registry.transient<IFileMenu, FileMenu>();
registry.transient<IWindowMenu, WindowMenu>();
trunk/product/MyMoney/boot/container/registration/wire_up_the_services_in_to_the.cs
@@ -52,7 +52,7 @@ namespace MoMoney.boot.container.registration
public void configure(IProxyBuilder<T> item)
{
- configure_it(item.add_interceptor(Lazy.load<IUnitOfWorkInterceptor>()).InterceptOn);
+ configure_it(item.add_interceptor(Lazy.load<IUnitOfWorkInterceptor>()).intercept_on);
}
}
}
\ No newline at end of file
trunk/product/MyMoney/boot/container/registration/wire_up_the_views_in_to_the.cs
@@ -1,8 +1,6 @@
using System.Threading;
using System.Windows.Forms;
using MoMoney.Infrastructure.Container;
-using MoMoney.Infrastructure.proxies;
-using MoMoney.Infrastructure.Threading;
using MoMoney.Presentation.Views;
using MoMoney.Presentation.Views.billing;
using MoMoney.Presentation.Views.dialogs;
@@ -28,17 +26,8 @@ namespace MoMoney.boot.container.registration
public void run()
{
var shell = new ApplicationShell();
- register.singleton(
- () =>
- {
- if (SynchronizationContext.Current == null)
- {
- SynchronizationContext.SetSynchronizationContext(new WindowsFormsSynchronizationContext());
- }
- return SynchronizationContext.Current;
- });
register.singleton<IShell>(() => shell);
- //register.proxy(new SynchronizedConfiguration<IShell>(), () => shell);
+ //register.proxy<IShell, SynchronizedConfiguration<IShell>>(() => shell);
register.singleton(() => shell);
register.transient<IAboutApplicationView, AboutTheApplicationView>();
register.transient<ISplashScreenView, SplashScreenView>();
@@ -58,12 +47,4 @@ namespace MoMoney.boot.container.registration
register.transient<ILogFileView, LogFileView>();
}
}
-
- internal class SynchronizedConfiguration<T> : IConfiguration<IProxyBuilder<T>>
- {
- public void configure(IProxyBuilder<T> item)
- {
- item.add_interceptor<ThreadSafeInterceptor>().InterceptAll();
- }
- }
}
\ No newline at end of file
trunk/product/MyMoney/Infrastructure/Container/Autofac/AutofacDependencyRegistryBuilder.cs
@@ -61,6 +61,12 @@ namespace MoMoney.Infrastructure.Container.Autofac
builder.Register(x => proxy_builder.create_proxy_for(target)).As<T>().FactoryScoped();
}
+ public void proxy<T, Configuration>(Func<T> target)
+ where Configuration : IConfiguration<IProxyBuilder<T>>, new()
+ {
+ proxy(new Configuration(), target);
+ }
+
public IDependencyRegistry build()
{
return new AutofacDependencyRegistry(container);
trunk/product/MyMoney/Infrastructure/Container/Windsor/WindsorDependencyRegistry.cs
@@ -69,6 +69,12 @@ namespace MoMoney.Infrastructure.Container.Windsor
singleton(builder.create_proxy_for(target));
}
+ public void proxy<T, Configuration>(Func<T> target)
+ where Configuration : IConfiguration<IProxyBuilder<T>>, new()
+ {
+ proxy(new Configuration(), target);
+ }
+
public IDependencyRegistry build()
{
return this;
trunk/product/MyMoney/Infrastructure/Container/IDependencyRegistration.cs
@@ -11,5 +11,6 @@ namespace MoMoney.Infrastructure.Container
void transient<Contract, Implementation>() where Implementation : Contract;
void transient(Type contract, Type implementation);
void proxy<T>(IConfiguration<IProxyBuilder<T>> configuration, Func<T> target);
+ void proxy<T, Configuration>(Func<T> target) where Configuration : IConfiguration<IProxyBuilder<T>>, new();
}
}
\ No newline at end of file
trunk/product/MyMoney/Infrastructure/proxies/IConstraintSelector.cs
@@ -2,7 +2,7 @@ namespace MoMoney.Infrastructure.proxies
{
public interface IConstraintSelector<TypeToPutConstraintOn>
{
- TypeToPutConstraintOn InterceptOn { get; }
- void InterceptAll();
+ TypeToPutConstraintOn intercept_on { get; }
+ void intercept_all();
}
}
\ No newline at end of file
trunk/product/MyMoney/Infrastructure/proxies/IInterceptorConstraint.cs
@@ -1,10 +1,7 @@
using System.Collections.Generic;
-using System.ComponentModel;
using System.Linq;
using System.Reflection;
-using MoMoney.Infrastructure.Extensions;
using MoMoney.Infrastructure.proxies.Interceptors;
-using MoMoney.Utility.Extensions;
namespace MoMoney.Infrastructure.proxies
{
@@ -16,47 +13,36 @@ namespace MoMoney.Infrastructure.proxies
public class InterceptorConstraint<TypeToPutConstraintOn> : IInterceptorConstraint<TypeToPutConstraintOn>
{
readonly IMethodCallTracker<TypeToPutConstraintOn> call_tracker;
+ bool intercept_all_calls;
public InterceptorConstraint(IMethodCallTracker<TypeToPutConstraintOn> call_tracker)
{
this.call_tracker = call_tracker;
}
- public TypeToPutConstraintOn InterceptOn
+ public TypeToPutConstraintOn intercept_on
{
get { return call_tracker.target; }
}
- public void InterceptAll()
+ public void intercept_all()
{
- var methods = typeof (TypeToPutConstraintOn).GetMethods(BindingFlags.Public | BindingFlags.Instance);
- foreach (var method in methods)
- {
- 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());
- }
- }
+ intercept_all_calls = true;
}
- IEnumerable<object> get_stub_parameters_for(MethodInfo method)
+ public IEnumerable<string> methods_to_intercept()
{
- foreach (var parameter in method.GetParameters())
- {
- this.log().debug("method: {0}, param: {1}", method, parameter);
- yield return parameter.ParameterType.default_value();
- }
+ return intercept_all_calls ? gell_all_methods() : call_tracker.methods_to_intercept();
}
- public IEnumerable<string> methods_to_intercept()
+ IEnumerable<string> gell_all_methods()
+ {
+ return all_methods().Select(x => x.Name);
+ }
+
+ IEnumerable<MethodInfo> all_methods()
{
- return call_tracker.methods_to_intercept();
+ return typeof (TypeToPutConstraintOn).GetMethods(BindingFlags.Public | BindingFlags.Instance);
}
}
}
\ No newline at end of file
trunk/product/MyMoney/Infrastructure/proxies/InterceptorConstraintSpecs.cs
@@ -48,7 +48,7 @@ namespace MoMoney.Infrastructure.proxies
method_call_tracker.is_told_to(t => t.target).it_will_return(target_of_interception);
};
- because b = () => { result = sut.InterceptOn; };
+ because b = () => { result = sut.intercept_on; };
it should_return_the_target_of_the_method_call_tracker =
() => result.should_be_equal_to(target_of_interception);
trunk/product/MyMoney/Infrastructure/proxies/ProxyBuilderSpecs.cs
@@ -70,7 +70,7 @@ namespace MoMoney.Infrastructure.proxies
because b = () =>
{
var constraint = sut.add_interceptor<SomeInterceptor>();
- constraint.InterceptOn.OneMethod();
+ constraint.intercept_on.OneMethod();
var proxy = sut.create_proxy_for(() => an_implementation);
proxy.OneMethod();
@@ -102,7 +102,7 @@ namespace MoMoney.Infrastructure.proxies
because b = () =>
{
var constraint = sut.add_interceptor<SomeInterceptor>();
- constraint.InterceptAll();
+ constraint.intercept_all();
var proxy = sut.create_proxy_for(() => an_implementation);
proxy.OneMethod();
trunk/product/MyMoney/Infrastructure/Threading/AsynchronousCommandProcessor.cs
@@ -46,8 +46,6 @@ namespace MoMoney.Infrastructure.Threading
{
keep_working = false;
manual_reset.Set();
- worker_thread.Abort();
- worker_thread = null;
}
[STAThread]
trunk/product/MyMoney/MyMoney.csproj
@@ -166,6 +166,7 @@
<ItemGroup>
<Compile Include="boot\container\registration\auto_wire_components_in_to_the.cs" />
<Compile Include="boot\container\registration\auto_wire_components_in_to_the_specs.cs" />
+ <Compile Include="boot\container\registration\SynchronizedConfiguration.cs" />
<Compile Include="boot\container\registration\wire_up_the_infrastructure_in_to_the.cs" />
<Compile Include="boot\container\tear_down_the_container.cs" />
<Compile Include="boot\container\registration\wire_up_the_data_access_components_into_the.cs" />