Commit 37dc043
Changed files (54)
build
product
Gorilla.Commons.Infrastructure
Cloning
FileSystem
Logging
Proxies
Reflection
Registries
Gorilla.Commons.Infrastructure.ThirdParty
Castle
DynamicProxy
Gorilla.Commons.Testing
Gorilla.Commons.Utility
build/Gorilla.Commons.Build.csproj → build/build.csproj
File renamed without changes
product/Gorilla.Commons.Infrastructure/Cloning/BinarySerializer.cs
@@ -2,7 +2,7 @@ using System.Runtime.Serialization.Formatters.Binary;
namespace Gorilla.Commons.Infrastructure.Cloning
{
- public class BinarySerializer<T> : Serializer<T>
+ public class BinarySerializer<T> : FileStreamSerializer<T>
{
public BinarySerializer(string file_path) : base(file_path, new BinaryFormatter())
{
product/Gorilla.Commons.Infrastructure/Cloning/BinarySerializerSpecs.cs
@@ -7,9 +7,9 @@ using MbUnit.Framework;
namespace Gorilla.Commons.Infrastructure.Cloning
{
[Concern(typeof (BinarySerializer<TestItem>))]
- public abstract class when_a_file_is_specified_to_serialize_an_item_to : concerns_for<ISerializer<TestItem>, BinarySerializer<TestItem>>
+ public abstract class when_a_file_is_specified_to_serialize_an_item_to : concerns_for<Serializer<TestItem>, BinarySerializer<TestItem>>
{
- public override ISerializer<TestItem> create_sut()
+ public override Serializer<TestItem> create_sut()
{
return new BinarySerializer<TestItem>(file_name);
}
product/Gorilla.Commons.Infrastructure/Cloning/FileStreamSerializer.cs
@@ -0,0 +1,34 @@
+using System.IO;
+using System.Runtime.Serialization;
+
+namespace Gorilla.Commons.Infrastructure.Cloning
+{
+ public class FileStreamSerializer<T> : Serializer<T>
+ {
+ public FileStreamSerializer(string file_path, IFormatter formatter)
+ {
+ this.file_path = file_path;
+ this.formatter = formatter;
+ }
+
+ public void serialize(T to_serialize)
+ {
+ using (var stream = new FileStream(file_path, FileMode.Create, FileAccess.Write))
+ formatter.Serialize(stream, to_serialize);
+ }
+
+ public T deserialize()
+ {
+ using (var stream = new FileStream(file_path, FileMode.Open, FileAccess.Read))
+ return (T) formatter.Deserialize(stream);
+ }
+
+ public void Dispose()
+ {
+ File.Delete(file_path);
+ }
+
+ readonly string file_path;
+ readonly IFormatter formatter;
+ }
+}
\ No newline at end of file
product/Gorilla.Commons.Infrastructure/Cloning/ISerializer.cs
@@ -1,10 +0,0 @@
-using System;
-
-namespace Gorilla.Commons.Infrastructure.Cloning
-{
- public interface ISerializer<T> : IDisposable
- {
- void serialize(T to_serialize);
- T deserialize();
- }
-}
\ No newline at end of file
product/Gorilla.Commons.Infrastructure/Cloning/Serializer.cs
@@ -1,34 +1,10 @@
-using System.IO;
-using System.Runtime.Serialization;
+using System;
namespace Gorilla.Commons.Infrastructure.Cloning
{
- public class Serializer<T> : ISerializer<T>
+ public interface Serializer<T> : IDisposable
{
- public Serializer(string file_path, IFormatter formatter)
- {
- this.file_path = file_path;
- this.formatter = formatter;
- }
-
- public void serialize(T to_serialize)
- {
- using (var stream = new FileStream(file_path, FileMode.Create, FileAccess.Write))
- formatter.Serialize(stream, to_serialize);
- }
-
- public T deserialize()
- {
- using (var stream = new FileStream(file_path, FileMode.Open, FileAccess.Read))
- return (T) formatter.Deserialize(stream);
- }
-
- public void Dispose()
- {
- File.Delete(file_path);
- }
-
- readonly string file_path;
- readonly IFormatter formatter;
+ void serialize(T to_serialize);
+ T deserialize();
}
}
\ No newline at end of file
product/Gorilla.Commons.Infrastructure/Container/DependencyRegistry.cs
@@ -0,0 +1,10 @@
+using System.Collections.Generic;
+
+namespace Gorilla.Commons.Infrastructure.Container
+{
+ public interface DependencyRegistry
+ {
+ Contract get_a<Contract>();
+ IEnumerable<Contract> get_all<Contract>();
+ }
+}
\ No newline at end of file
product/Gorilla.Commons.Infrastructure/Container/IDependencyRegistry.cs
@@ -1,10 +0,0 @@
-using System.Collections.Generic;
-
-namespace Gorilla.Commons.Infrastructure.Container
-{
- public interface IDependencyRegistry
- {
- Interface get_a<Interface>();
- IEnumerable<Interface> all_the<Interface>();
- }
-}
\ No newline at end of file
product/Gorilla.Commons.Infrastructure/Container/Resolve.cs
@@ -4,10 +4,10 @@ namespace Gorilla.Commons.Infrastructure.Container
{
static public class Resolve
{
- static IDependencyRegistry underlying_registry;
+ static DependencyRegistry underlying_registry;
static bool initialized;
- static public void initialize_with(IDependencyRegistry registry)
+ static public void initialize_with(DependencyRegistry registry)
{
underlying_registry = registry;
initialized = registry != null;
product/Gorilla.Commons.Infrastructure/Container/ResolveSpecs.cs
@@ -15,7 +15,7 @@ namespace Gorilla.Commons.Infrastructure.Container
{
context c = () =>
{
- registry = an<IDependencyRegistry>();
+ registry = an<DependencyRegistry>();
presenter = an<Command>();
registry.is_told_to(x => x.get_a<Command>()).it_will_return(presenter);
Resolve.initialize_with(registry);
@@ -30,7 +30,7 @@ namespace Gorilla.Commons.Infrastructure.Container
after_each_observation a = () => Resolve.initialize_with(null);
- static IDependencyRegistry registry;
+ static DependencyRegistry registry;
static Command result;
static Command presenter;
}
@@ -40,7 +40,7 @@ namespace Gorilla.Commons.Infrastructure.Container
{
context c = () =>
{
- registry = an<IDependencyRegistry>();
+ registry = an<DependencyRegistry>();
registry.is_told_to(x => x.get_a<Command>()).it_will_throw(new Exception());
Resolve.initialize_with(registry);
};
@@ -52,7 +52,7 @@ namespace Gorilla.Commons.Infrastructure.Container
it should_throw_a_dependency_resolution_exception =
() => the_call.should_have_thrown<DependencyResolutionException<Command>>();
- static IDependencyRegistry registry;
+ static DependencyRegistry registry;
static Action the_call;
}
}
\ No newline at end of file
product/Gorilla.Commons.Infrastructure/FileSystem/ApplicationFile.cs
@@ -1,8 +1,6 @@
-using System.IO;
-
namespace Gorilla.Commons.Infrastructure.FileSystem
{
- public class ApplicationFile : IFile
+ public class ApplicationFile : File
{
public ApplicationFile(string path)
{
@@ -13,17 +11,17 @@ namespace Gorilla.Commons.Infrastructure.FileSystem
public virtual bool does_the_file_exist()
{
- return !string.IsNullOrEmpty(path) && File.Exists(path);
+ return !string.IsNullOrEmpty(path) && System.IO.File.Exists(path);
}
public void copy_to(string other_path)
{
- File.Copy(path, other_path, true);
+ System.IO.File.Copy(path, other_path, true);
}
public void delete()
{
- File.Delete(path);
+ System.IO.File.Delete(path);
}
public static implicit operator ApplicationFile(string file_path)
product/Gorilla.Commons.Infrastructure/FileSystem/IFile.cs → product/Gorilla.Commons.Infrastructure/FileSystem/File.cs
@@ -1,6 +1,6 @@
namespace Gorilla.Commons.Infrastructure.FileSystem
{
- public interface IFile
+ public interface File
{
string path { get; }
bool does_the_file_exist();
product/Gorilla.Commons.Infrastructure/Logging/LogSpecs.cs
@@ -13,7 +13,7 @@ namespace Gorilla.Commons.Infrastructure.Logging
() =>
{
var factory = an<LogFactory>();
- var registry = an<IDependencyRegistry>();
+ var registry = an<DependencyRegistry>();
logger = an<Logger>();
registry.is_told_to(x => x.get_a<LogFactory>()).it_will_return(factory);
factory.is_told_to(x => x.create_for(typeof (string))).it_will_return(logger);
product/Gorilla.Commons.Infrastructure/Proxies/IInterceptor.cs
@@ -1,7 +0,0 @@
-namespace Gorilla.Commons.Infrastructure.Proxies
-{
- public interface IInterceptor
- {
- void intercept(IInvocation invocation);
- }
-}
\ No newline at end of file
product/Gorilla.Commons.Infrastructure/Proxies/Interceptor.cs
@@ -0,0 +1,7 @@
+namespace Gorilla.Commons.Infrastructure.Proxies
+{
+ public interface Interceptor
+ {
+ void intercept(Invocation invocation);
+ }
+}
\ No newline at end of file
product/Gorilla.Commons.Infrastructure/Proxies/IInvocation.cs → product/Gorilla.Commons.Infrastructure/Proxies/Invocation.cs
@@ -2,7 +2,7 @@ using System.Reflection;
namespace Gorilla.Commons.Infrastructure.Proxies
{
- public interface IInvocation
+ public interface Invocation
{
void proceed();
object[] arguments { get; }
product/Gorilla.Commons.Infrastructure/Proxies/MethodCallInvocation.cs
@@ -5,17 +5,17 @@ using gorilla.commons.utility;
namespace Gorilla.Commons.Infrastructure.Proxies
{
- public class MethodCallInvocation<T> : IInvocation
+ public class MethodCallInvocation<T> : Invocation
{
readonly IMethodCallMessage call;
readonly T target;
- readonly Stack<IInterceptor> interceptors;
+ readonly Stack<Interceptor> interceptors;
- public MethodCallInvocation(IEnumerable<IInterceptor> interceptors, IMethodCallMessage call, T target)
+ public MethodCallInvocation(IEnumerable<Interceptor> interceptors, IMethodCallMessage call, T target)
{
this.call = call;
this.target = target;
- this.interceptors = new Stack<IInterceptor>(interceptors);
+ this.interceptors = new Stack<Interceptor>(interceptors);
arguments = call.Properties["__Args"].downcast_to<object[]>();
method = call.MethodBase.downcast_to<MethodInfo>();
}
product/Gorilla.Commons.Infrastructure/Proxies/ProxyFactory.cs
@@ -2,7 +2,7 @@ namespace Gorilla.Commons.Infrastructure.Proxies
{
static public class ProxyFactory
{
- static public T create<T>(T target, params IInterceptor[] interceptors)
+ static public T create<T>(T target, params Interceptor[] interceptors)
{
return new RemotingProxyFactory<T>(target, interceptors).create_proxy();
}
product/Gorilla.Commons.Infrastructure/Proxies/ProxyFactorySpecs.cs
@@ -25,7 +25,7 @@ namespace Gorilla.Commons.Infrastructure.Proxies
static Person marshal_mathers;
static IPerson some_celebrity;
- static IInterceptor interceptors;
+ static Interceptor interceptors;
}
public interface IPerson
@@ -48,9 +48,9 @@ namespace Gorilla.Commons.Infrastructure.Proxies
}
}
- public class MyNameIsSlimShadyInterceptor : IInterceptor
+ public class MyNameIsSlimShadyInterceptor : Interceptor
{
- public void intercept(IInvocation invocation)
+ public void intercept(Invocation invocation)
{
invocation.proceed();
invocation.return_value = "slim shady";
product/Gorilla.Commons.Infrastructure/Proxies/RemotingProxyFactory.cs
@@ -8,9 +8,9 @@ namespace Gorilla.Commons.Infrastructure.Proxies
public class RemotingProxyFactory<T> : RealProxy
{
readonly T target;
- readonly IEnumerable<IInterceptor> interceptors;
+ readonly IEnumerable<Interceptor> interceptors;
- public RemotingProxyFactory(T target, IEnumerable<IInterceptor> interceptors) : base(typeof (T))
+ public RemotingProxyFactory(T target, IEnumerable<Interceptor> interceptors) : base(typeof (T))
{
this.target = target;
this.interceptors = interceptors;
product/Gorilla.Commons.Infrastructure/Reflection/ApplicationAssembly.cs
@@ -1,14 +1,13 @@
using System;
using System.Collections.Generic;
-using System.Reflection;
namespace Gorilla.Commons.Infrastructure.Reflection
{
- public class ApplicationAssembly : IAssembly
+ public class ApplicationAssembly : Assembly
{
- readonly Assembly assembly;
+ readonly System.Reflection.Assembly assembly;
- public ApplicationAssembly(Assembly assembly)
+ public ApplicationAssembly(System.Reflection.Assembly assembly)
{
this.assembly = assembly;
}
product/Gorilla.Commons.Infrastructure/Reflection/IAssembly.cs → product/Gorilla.Commons.Infrastructure/Reflection/Assembly.cs
@@ -3,7 +3,7 @@ using System.Collections.Generic;
namespace Gorilla.Commons.Infrastructure.Reflection
{
- public interface IAssembly
+ public interface Assembly
{
IEnumerable<Type> all_types();
}
product/Gorilla.Commons.Infrastructure/Registries/DefaultRegistry.cs
@@ -7,16 +7,16 @@ namespace Gorilla.Commons.Infrastructure.Registries
{
public class DefaultRegistry<T> : Registry<T>
{
- readonly IDependencyRegistry registry;
+ readonly DependencyRegistry registry;
- public DefaultRegistry(IDependencyRegistry registry)
+ public DefaultRegistry(DependencyRegistry registry)
{
this.registry = registry;
}
public IEnumerable<T> all()
{
- return registry.all_the<T>();
+ return registry.get_all<T>();
}
public IEnumerator<T> GetEnumerator()
product/Gorilla.Commons.Infrastructure/Registries/DefaultRegistrySpecs.cs
@@ -11,15 +11,15 @@ namespace Gorilla.Commons.Infrastructure.Registries
concerns_for<Registry<int>, DefaultRegistry<int>>
{
it should_leverage_the_resolver_to_retrieve_all_the_implementations =
- () => registry.was_told_to(r => r.all_the<int>());
+ () => registry.was_told_to(r => r.get_all<int>());
it should_return_the_items_resolved_by_the_registry = () => result.should_contain(24);
context c = () =>
{
var items_to_return = new List<int> {24};
- registry = an<IDependencyRegistry>();
- registry.is_told_to(r => r.all_the<int>()).it_will_return(items_to_return);
+ registry = an<DependencyRegistry>();
+ registry.is_told_to(r => r.get_all<int>()).it_will_return(items_to_return);
};
public override Registry<int> create_sut()
@@ -29,7 +29,7 @@ namespace Gorilla.Commons.Infrastructure.Registries
because b = () => { result = sut.all(); };
- static IDependencyRegistry registry;
+ static DependencyRegistry registry;
static IEnumerable<int> result;
}
}
\ No newline at end of file
product/Gorilla.Commons.Infrastructure/Gorilla.Commons.Infrastructure.csproj → product/Gorilla.Commons.Infrastructure/infrastructure.csproj
@@ -8,8 +8,8 @@
<ProjectGuid>{AA5EEED9-4531-45F7-AFCD-AD9717D2E405}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
- <RootNamespace>Gorilla.Commons.Infrastructure</RootNamespace>
- <AssemblyName>Gorilla.Commons.Infrastructure</AssemblyName>
+ <RootNamespace>gorilla.commons.infrastructure</RootNamespace>
+ <AssemblyName>gorilla.commons.infrastructure</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
@@ -63,16 +63,16 @@
<ItemGroup>
<Compile Include="Cloning\BinarySerializer.cs" />
<Compile Include="Cloning\BinarySerializerSpecs.cs" />
- <Compile Include="Cloning\ISerializer.cs" />
- <Compile Include="Cloning\Prototype.cs" />
<Compile Include="Cloning\Serializer.cs" />
+ <Compile Include="Cloning\Prototype.cs" />
+ <Compile Include="Cloning\FileStreamSerializer.cs" />
<Compile Include="Container\DependencyResolutionException.cs" />
- <Compile Include="Container\IDependencyRegistry.cs" />
+ <Compile Include="Container\DependencyRegistry.cs" />
<Compile Include="Container\Resolve.cs" />
<Compile Include="Container\ResolveSpecs.cs" />
<Compile Include="Debugging\Launch.cs" />
<Compile Include="FileSystem\ApplicationFile.cs" />
- <Compile Include="FileSystem\IFile.cs" />
+ <Compile Include="FileSystem\File.cs" />
<Compile Include="Logging\TextLogger.cs" />
<Compile Include="Logging\LogFactory.cs" />
<Compile Include="Logging\Loggable.cs" />
@@ -81,22 +81,22 @@
<Compile Include="Logging\LoggingExtensions.cs" />
<Compile Include="Logging\LogSpecs.cs" />
<Compile Include="Proxies\ExceptionExtensions.cs" />
- <Compile Include="Proxies\IInterceptor.cs" />
- <Compile Include="Proxies\IInvocation.cs" />
+ <Compile Include="Proxies\Interceptor.cs" />
+ <Compile Include="Proxies\Invocation.cs" />
<Compile Include="Proxies\MethodCallInvocation.cs" />
<Compile Include="Proxies\ProxyFactory.cs" />
<Compile Include="Proxies\ProxyFactorySpecs.cs" />
<Compile Include="Proxies\RemotingProxyFactory.cs" />
<Compile Include="Reflection\ApplicationAssembly.cs" />
<Compile Include="Reflection\EnvironmentExtensions.cs" />
- <Compile Include="Reflection\IAssembly.cs" />
+ <Compile Include="Reflection\Assembly.cs" />
<Compile Include="Registries\DefaultRegistry.cs" />
<Compile Include="Registries\DefaultRegistrySpecs.cs" />
</ItemGroup>
<ItemGroup>
- <ProjectReference Include="..\Gorilla.Commons.Testing\Gorilla.Commons.Testing.csproj">
+ <ProjectReference Include="..\Gorilla.Commons.Testing\test.helpers.csproj">
<Project>{44E65096-9657-4716-90F8-4535BABE8039}</Project>
- <Name>Gorilla.Commons.Testing</Name>
+ <Name>test.helpers</Name>
</ProjectReference>
<ProjectReference Include="..\Gorilla.Commons.Utility\utility.csproj">
<Project>{DD8FD29E-7424-415C-9BA3-7D9F6ECBA161}</Project>
product/Gorilla.Commons.Infrastructure.ThirdParty/Autofac/AutofacDependencyRegistry.cs
@@ -5,7 +5,7 @@ using Gorilla.Commons.Infrastructure.Container;
namespace Gorilla.Commons.Infrastructure.Autofac
{
- internal class AutofacDependencyRegistry : IDependencyRegistry
+ internal class AutofacDependencyRegistry : DependencyRegistry
{
readonly Func<IContainer> container;
@@ -19,7 +19,7 @@ namespace Gorilla.Commons.Infrastructure.Autofac
return container().Resolve<Interface>();
}
- public IEnumerable<Interface> all_the<Interface>()
+ public IEnumerable<Interface> get_all<Interface>()
{
return container().Resolve<IEnumerable<Interface>>();
}
product/Gorilla.Commons.Infrastructure.ThirdParty/Autofac/AutofacDependencyRegistryBuilder.cs
@@ -3,11 +3,14 @@ using Autofac;
using Autofac.Builder;
using Autofac.Modules;
using AutofacContrib.DynamicProxy2;
+using Gorilla.Commons.Infrastructure;
+using Gorilla.Commons.Infrastructure.Autofac;
using Gorilla.Commons.Infrastructure.Castle.DynamicProxy;
using Gorilla.Commons.Infrastructure.Container;
+using gorilla.commons.infrastructure.thirdparty.Castle.DynamicProxy;
using gorilla.commons.utility;
-namespace Gorilla.Commons.Infrastructure.Autofac
+namespace gorilla.commons.infrastructure.thirdparty.Autofac
{
public class AutofacDependencyRegistryBuilder : IDependencyRegistration
{
@@ -51,20 +54,20 @@ namespace Gorilla.Commons.Infrastructure.Autofac
builder.Register(implementation).As(contract).FactoryScoped();
}
- public void proxy<T>(Configuration<IProxyBuilder<T>> configuration, Func<T> target)
+ public void proxy<T>(Configuration<ProxyBuilder<T>> configuration, Func<T> target)
{
- var proxy_builder = new ProxyBuilder<T>();
+ var proxy_builder = new CastleDynamicProxyBuilder<T>();
configuration.configure(proxy_builder);
builder.Register(x => proxy_builder.create_proxy_for(target)).As<T>().FactoryScoped();
}
public void proxy<T, Configuration>(Func<T> target)
- where Configuration : Configuration<IProxyBuilder<T>>, new()
+ where Configuration : Configuration<ProxyBuilder<T>>, new()
{
proxy(new Configuration(), target);
}
- public IDependencyRegistry build()
+ public DependencyRegistry build()
{
return new AutofacDependencyRegistry(container);
}
product/Gorilla.Commons.Infrastructure.ThirdParty/Castle/DynamicProxy/Interceptors/IMethodCallTracker.cs
@@ -1,7 +1,7 @@
using System.Collections.Generic;
using Castle.Core.Interceptor;
-namespace Gorilla.Commons.Infrastructure.Castle.DynamicProxy.Interceptors
+namespace gorilla.commons.infrastructure.thirdparty.Castle.DynamicProxy.Interceptors
{
public interface IMethodCallTracker<TypeToProxy> : IInterceptor
{
product/Gorilla.Commons.Infrastructure.ThirdParty/Castle/DynamicProxy/Interceptors/MethodCallTracker.cs
@@ -2,7 +2,7 @@ using System.Collections.Generic;
using Castle.Core.Interceptor;
using gorilla.commons.utility;
-namespace Gorilla.Commons.Infrastructure.Castle.DynamicProxy.Interceptors
+namespace gorilla.commons.infrastructure.thirdparty.Castle.DynamicProxy.Interceptors
{
public class MethodCallTracker<TypeToProxy> : IMethodCallTracker<TypeToProxy>
{
product/Gorilla.Commons.Infrastructure.ThirdParty/Castle/DynamicProxy/Interceptors/MethodCallTrackerSpecs.cs
@@ -4,7 +4,7 @@ using Castle.Core.Interceptor;
using developwithpassion.bdd.contexts;
using Gorilla.Commons.Testing;
-namespace Gorilla.Commons.Infrastructure.Castle.DynamicProxy.Interceptors
+namespace gorilla.commons.infrastructure.thirdparty.Castle.DynamicProxy.Interceptors
{
[Concern(typeof (MethodCallTracker<>))]
public class behaves_like_method_call_tracker :
@@ -23,18 +23,18 @@ namespace Gorilla.Commons.Infrastructure.Castle.DynamicProxy.Interceptors
static IEnumerable<string> result;
context c = () =>
- {
- invocation = an<IInvocation>();
- invocation
- .is_told_to(s => s.Method)
- .it_will_return(typeof (IAnInterface).GetMethod("ValueReturningMethodWithAnArgument"));
- };
+ {
+ invocation = an<IInvocation>();
+ invocation
+ .is_told_to(s => s.Method)
+ .it_will_return(typeof (IAnInterface).GetMethod("ValueReturningMethodWithAnArgument"));
+ };
because b = () =>
- {
- sut.Intercept(invocation);
- result = sut.methods_to_intercept();
- };
+ {
+ sut.Intercept(invocation);
+ result = sut.methods_to_intercept();
+ };
it should_return_all_the_methods_that_are_specified_for_interception =
() => result.should_contain(typeof (IAnInterface).GetMethod("ValueReturningMethodWithAnArgument").Name);
product/Gorilla.Commons.Infrastructure.ThirdParty/Castle/DynamicProxy/CastleDynamicProxyBuilder.cs
@@ -0,0 +1,67 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Castle.Core.Interceptor;
+using Gorilla.Commons.Infrastructure.Castle.DynamicProxy;
+using Gorilla.Commons.Infrastructure.Castle.DynamicProxy.Interceptors;
+
+namespace gorilla.commons.infrastructure.thirdparty.Castle.DynamicProxy
+{
+ public class CastleDynamicProxyBuilder<TypeToProxy> : ProxyBuilder<TypeToProxy>
+ {
+ readonly IDictionary<IInterceptor, IInterceptorConstraint<TypeToProxy>> constraints;
+ readonly ProxyFactory proxy_factory;
+ readonly IInterceptorConstraintFactory constraint_factory;
+
+ public CastleDynamicProxyBuilder() : this(new CastleDynamicProxyFactory(), new InterceptorConstraintFactory())
+ {
+ }
+
+ public CastleDynamicProxyBuilder(ProxyFactory proxy_factory, IInterceptorConstraintFactory constraint_factory)
+ {
+ this.proxy_factory = proxy_factory;
+ this.constraint_factory = constraint_factory;
+ constraints = new Dictionary<IInterceptor, IInterceptorConstraint<TypeToProxy>>();
+ }
+
+ public ConstraintSelector<TypeToProxy> add_interceptor<Interceptor>(Interceptor interceptor)
+ where Interceptor : IInterceptor
+ {
+ var constraint = constraint_factory.CreateFor<TypeToProxy>();
+ constraints.Add(interceptor, constraint);
+ return constraint;
+ }
+
+ public ConstraintSelector<TypeToProxy> add_interceptor<Interceptor>() where Interceptor : IInterceptor, new()
+ {
+ return add_interceptor(new Interceptor());
+ }
+
+ public TypeToProxy create_proxy_for(TypeToProxy target)
+ {
+ return create_proxy_for(() => target);
+ }
+
+ public TypeToProxy create_proxy_for(Func<TypeToProxy> target)
+ {
+ return proxy_factory.create_proxy_for(target, all_interceptors_with_their_constraints().ToArray());
+ }
+
+ IEnumerable<IInterceptor> all_interceptors_with_their_constraints()
+ {
+ foreach (var pair in constraints)
+ {
+ var constraint = pair.Value;
+ var interceptor = pair.Key;
+ if (constraint.methods_to_intercept().Count() > 0)
+ {
+ yield return new SelectiveInterceptor(constraint.methods_to_intercept(), interceptor);
+ }
+ else
+ {
+ yield return interceptor;
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
product/Gorilla.Commons.Infrastructure.ThirdParty/Castle/DynamicProxy/CastleDynamicProxyFactory.cs
@@ -0,0 +1,49 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Castle.Core.Interceptor;
+using Castle.DynamicProxy;
+using Gorilla.Commons.Infrastructure.Castle.DynamicProxy;
+
+namespace gorilla.commons.infrastructure.thirdparty.Castle.DynamicProxy
+{
+ public class CastleDynamicProxyFactory : ProxyFactory
+ {
+ readonly ProxyGenerator generator;
+
+ public CastleDynamicProxyFactory() : this(new ProxyGenerator())
+ {
+ }
+
+ public CastleDynamicProxyFactory(ProxyGenerator generator)
+ {
+ this.generator = generator;
+ }
+
+ public TypeToProxy create_proxy_for<TypeToProxy>(Func<TypeToProxy> implementation, params IInterceptor[] interceptors)
+ {
+ return create_proxy_for(lazy_load(implementation), interceptors);
+ }
+
+ T lazy_load<T>(Func<T> implementation)
+ {
+ if (typeof (T).IsInterface)
+ {
+ return generator.CreateInterfaceProxyWithoutTarget<T>(new LazyLoadedInterceptor<T>(implementation));
+ }
+ return generator.CreateClassProxy<T>(new LazyLoadedInterceptor<T>(implementation));
+ }
+
+ TypeToProxy create_proxy_for<TypeToProxy>(TypeToProxy implementation,
+ IEnumerable<IInterceptor> interceptors)
+ {
+ if (typeof (TypeToProxy).IsInterface)
+ {
+ return generator.CreateInterfaceProxyWithTarget<TypeToProxy>(implementation, interceptors.ToArray());
+ }
+ var list = interceptors.ToList();
+ list.Add(new LazyLoadedInterceptor<TypeToProxy>(() => implementation));
+ return generator.CreateClassProxy<TypeToProxy>(list.ToArray());
+ }
+ }
+}
\ No newline at end of file
product/Gorilla.Commons.Infrastructure.ThirdParty/Castle/DynamicProxy/IConstraintSelector.cs → product/Gorilla.Commons.Infrastructure.ThirdParty/Castle/DynamicProxy/ConstraintSelector.cs
@@ -1,6 +1,6 @@
namespace Gorilla.Commons.Infrastructure.Castle.DynamicProxy
{
- public interface IConstraintSelector<TypeToPutConstraintOn>
+ public interface ConstraintSelector<TypeToPutConstraintOn>
{
TypeToPutConstraintOn intercept_on { get; }
void intercept_all();
product/Gorilla.Commons.Infrastructure.ThirdParty/Castle/DynamicProxy/IInterceptorConstraint.cs
@@ -1,11 +1,12 @@
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
-using Gorilla.Commons.Infrastructure.Castle.DynamicProxy.Interceptors;
+using Gorilla.Commons.Infrastructure.Castle.DynamicProxy;
+using gorilla.commons.infrastructure.thirdparty.Castle.DynamicProxy.Interceptors;
-namespace Gorilla.Commons.Infrastructure.Castle.DynamicProxy
+namespace gorilla.commons.infrastructure.thirdparty.Castle.DynamicProxy
{
- public interface IInterceptorConstraint<TypeToPutConstraintOn> : IConstraintSelector<TypeToPutConstraintOn>
+ public interface IInterceptorConstraint<TypeToPutConstraintOn> : ConstraintSelector<TypeToPutConstraintOn>
{
IEnumerable<string> methods_to_intercept();
}
product/Gorilla.Commons.Infrastructure.ThirdParty/Castle/DynamicProxy/IInterceptorConstraintFactory.cs
@@ -1,4 +1,4 @@
-namespace Gorilla.Commons.Infrastructure.Castle.DynamicProxy
+namespace gorilla.commons.infrastructure.thirdparty.Castle.DynamicProxy
{
public interface IInterceptorConstraintFactory
{
product/Gorilla.Commons.Infrastructure.ThirdParty/Castle/DynamicProxy/IMethodCallTrackerFactory.cs
@@ -1,7 +1,7 @@
using Castle.DynamicProxy;
-using Gorilla.Commons.Infrastructure.Castle.DynamicProxy.Interceptors;
+using gorilla.commons.infrastructure.thirdparty.Castle.DynamicProxy.Interceptors;
-namespace Gorilla.Commons.Infrastructure.Castle.DynamicProxy
+namespace gorilla.commons.infrastructure.thirdparty.Castle.DynamicProxy
{
public interface IMethodCallTrackerFactory
{
product/Gorilla.Commons.Infrastructure.ThirdParty/Castle/DynamicProxy/InterceptorConstraintFactorySpecs.cs
@@ -1,7 +1,7 @@
using developwithpassion.bdd.contexts;
using Gorilla.Commons.Testing;
-namespace Gorilla.Commons.Infrastructure.Castle.DynamicProxy
+namespace gorilla.commons.infrastructure.thirdparty.Castle.DynamicProxy
{
[Concern(typeof (InterceptorConstraintFactory))]
public abstract class behaves_like_constraint_factory :
product/Gorilla.Commons.Infrastructure.ThirdParty/Castle/DynamicProxy/InterceptorConstraintSpecs.cs
@@ -1,9 +1,9 @@
using System.Collections.Generic;
using developwithpassion.bdd.contexts;
-using Gorilla.Commons.Infrastructure.Castle.DynamicProxy.Interceptors;
+using gorilla.commons.infrastructure.thirdparty.Castle.DynamicProxy.Interceptors;
using Gorilla.Commons.Testing;
-namespace Gorilla.Commons.Infrastructure.Castle.DynamicProxy
+namespace gorilla.commons.infrastructure.thirdparty.Castle.DynamicProxy
{
[Concern(typeof (InterceptorConstraint<>))]
public abstract class behaves_like_constraint : concerns_for<IInterceptorConstraint<string>, InterceptorConstraint<string>>
@@ -23,12 +23,12 @@ namespace Gorilla.Commons.Infrastructure.Castle.DynamicProxy
() => result.should_be_equal_to(methods_to_intercept);
context c = () =>
- {
- methods_to_intercept = new List<string>();
- method_call_tracker
- .is_told_to(t => t.methods_to_intercept())
- .it_will_return(methods_to_intercept);
- };
+ {
+ methods_to_intercept = new List<string>();
+ method_call_tracker
+ .is_told_to(t => t.methods_to_intercept())
+ .it_will_return(methods_to_intercept);
+ };
because b = () => { result = sut.methods_to_intercept(); };
}
@@ -42,10 +42,10 @@ namespace Gorilla.Commons.Infrastructure.Castle.DynamicProxy
const int target_of_interception = 7;
context c = () =>
- {
- method_call_tracker = the_dependency<IMethodCallTracker<int>>();
- method_call_tracker.is_told_to(t => t.target).it_will_return(target_of_interception);
- };
+ {
+ method_call_tracker = the_dependency<IMethodCallTracker<int>>();
+ method_call_tracker.is_told_to(t => t.target).it_will_return(target_of_interception);
+ };
because b = () => { result = sut.intercept_on; };
product/Gorilla.Commons.Infrastructure.ThirdParty/Castle/DynamicProxy/IProxyBuilder.cs
@@ -1,15 +0,0 @@
-using System;
-using Castle.Core.Interceptor;
-
-namespace Gorilla.Commons.Infrastructure.Castle.DynamicProxy
-{
- public interface IProxyBuilder<TypeToProxy>
- {
- IConstraintSelector<TypeToProxy> add_interceptor<Interceptor>(Interceptor interceptor)
- where Interceptor : IInterceptor;
-
- IConstraintSelector<TypeToProxy> add_interceptor<Interceptor>() where Interceptor : IInterceptor, new();
- TypeToProxy create_proxy_for(TypeToProxy target);
- TypeToProxy create_proxy_for(Func<TypeToProxy> target);
- }
-}
\ No newline at end of file
product/Gorilla.Commons.Infrastructure.ThirdParty/Castle/DynamicProxy/IProxyFactory.cs
@@ -1,10 +0,0 @@
-using System;
-using Castle.Core.Interceptor;
-
-namespace Gorilla.Commons.Infrastructure.Castle.DynamicProxy
-{
- public interface IProxyFactory
- {
- TypeToProxy create_proxy_for<TypeToProxy>(Func<TypeToProxy> implementation, params IInterceptor[] interceptors);
- }
-}
\ No newline at end of file
product/Gorilla.Commons.Infrastructure.ThirdParty/Castle/DynamicProxy/ProxyBuilder.cs
@@ -1,66 +1,15 @@
using System;
-using System.Collections.Generic;
-using System.Linq;
using Castle.Core.Interceptor;
-using Gorilla.Commons.Infrastructure.Castle.DynamicProxy.Interceptors;
namespace Gorilla.Commons.Infrastructure.Castle.DynamicProxy
{
- public class ProxyBuilder<TypeToProxy> : IProxyBuilder<TypeToProxy>
+ public interface ProxyBuilder<TypeToProxy>
{
- readonly IDictionary<IInterceptor, IInterceptorConstraint<TypeToProxy>> constraints;
- readonly IProxyFactory proxy_factory;
- readonly IInterceptorConstraintFactory constraint_factory;
+ ConstraintSelector<TypeToProxy> add_interceptor<Interceptor>(Interceptor interceptor)
+ where Interceptor : IInterceptor;
- public ProxyBuilder() : this(new ProxyFactory(), new InterceptorConstraintFactory())
- {
- }
-
- public ProxyBuilder(IProxyFactory proxy_factory, IInterceptorConstraintFactory constraint_factory)
- {
- this.proxy_factory = proxy_factory;
- this.constraint_factory = constraint_factory;
- constraints = new Dictionary<IInterceptor, IInterceptorConstraint<TypeToProxy>>();
- }
-
- public IConstraintSelector<TypeToProxy> add_interceptor<Interceptor>(Interceptor interceptor)
- where Interceptor : IInterceptor
- {
- var constraint = constraint_factory.CreateFor<TypeToProxy>();
- constraints.Add(interceptor, constraint);
- return constraint;
- }
-
- public IConstraintSelector<TypeToProxy> add_interceptor<Interceptor>() where Interceptor : IInterceptor, new()
- {
- return add_interceptor(new Interceptor());
- }
-
- public TypeToProxy create_proxy_for(TypeToProxy target)
- {
- return create_proxy_for(() => target);
- }
-
- public TypeToProxy create_proxy_for(Func<TypeToProxy> target)
- {
- return proxy_factory.create_proxy_for(target, all_interceptors_with_their_constraints().ToArray());
- }
-
- IEnumerable<IInterceptor> all_interceptors_with_their_constraints()
- {
- foreach (var pair in constraints)
- {
- var constraint = pair.Value;
- var interceptor = pair.Key;
- if (constraint.methods_to_intercept().Count() > 0)
- {
- yield return new SelectiveInterceptor(constraint.methods_to_intercept(), interceptor);
- }
- else
- {
- yield return interceptor;
- }
- }
- }
+ ConstraintSelector<TypeToProxy> add_interceptor<Interceptor>() where Interceptor : IInterceptor, new();
+ TypeToProxy create_proxy_for(TypeToProxy target);
+ TypeToProxy create_proxy_for(Func<TypeToProxy> target);
}
}
\ No newline at end of file
product/Gorilla.Commons.Infrastructure.ThirdParty/Castle/DynamicProxy/ProxyBuilderSpecs.cs
@@ -4,118 +4,119 @@ using System.Linq;
using System.Reflection;
using Castle.Core.Interceptor;
using developwithpassion.bdd.contexts;
+using Gorilla.Commons.Infrastructure.Castle.DynamicProxy;
using Gorilla.Commons.Testing;
-namespace Gorilla.Commons.Infrastructure.Castle.DynamicProxy
+namespace gorilla.commons.infrastructure.thirdparty.Castle.DynamicProxy
{
- [Concern(typeof (ProxyBuilder<>))]
- public abstract class behaves_like_proxy_builder : concerns_for<IProxyBuilder<IAnInterface>, ProxyBuilder<IAnInterface>>
+ [Concern(typeof (CastleDynamicProxyBuilder<>))]
+ public abstract class behaves_like_proxy_builder : concerns_for<ProxyBuilder<IAnInterface>, CastleDynamicProxyBuilder<IAnInterface>>
{
- public override IProxyBuilder<IAnInterface> create_sut()
+ public override ProxyBuilder<IAnInterface> create_sut()
{
- return new ProxyBuilder<IAnInterface>();
+ return new CastleDynamicProxyBuilder<IAnInterface>();
}
}
- [Concern(typeof (ProxyBuilder<>))]
+ [Concern(typeof (CastleDynamicProxyBuilder<>))]
public class when_building_a_proxy_for_a_type : behaves_like_proxy_builder
{
it should_make_sure_the_original_call_gets_forwarded_to_the_item_to_proxy =
() =>
- {
- an_implementation_of_the_interface.was_told_to(i => i.OneMethod());
- an_implementation_of_the_interface.was_told_to(i => i.SecondMethod());
- };
+ {
+ an_implementation_of_the_interface.was_told_to(i => i.OneMethod());
+ an_implementation_of_the_interface.was_told_to(i => i.SecondMethod());
+ };
it should_allow_each_intercepter_to_intercept_the_call =
() =>
- {
- SomeInterceptor.MethodsCalled.Count().should_be_equal_to(2);
- AnotherInterceptor.MethodsCalled.Count().should_be_equal_to(2);
- };
+ {
+ SomeInterceptor.MethodsCalled.Count().should_be_equal_to(2);
+ AnotherInterceptor.MethodsCalled.Count().should_be_equal_to(2);
+ };
context c = () => { an_implementation_of_the_interface = an<IAnInterface>(); };
because b = () =>
- {
- sut.add_interceptor<SomeInterceptor>();
- sut.add_interceptor<AnotherInterceptor>();
- var proxy = sut.create_proxy_for(() => an_implementation_of_the_interface);
- proxy.OneMethod();
- proxy.SecondMethod();
- };
+ {
+ sut.add_interceptor<SomeInterceptor>();
+ sut.add_interceptor<AnotherInterceptor>();
+ var proxy = sut.create_proxy_for(() => an_implementation_of_the_interface);
+ proxy.OneMethod();
+ proxy.SecondMethod();
+ };
after_each_observation ae = () =>
- {
- SomeInterceptor.Cleanup();
- AnotherInterceptor.Cleanup();
- };
+ {
+ SomeInterceptor.Cleanup();
+ AnotherInterceptor.Cleanup();
+ };
static IAnInterface an_implementation_of_the_interface;
}
[Integration]
- [Concern(typeof (ProxyBuilder<>))]
+ [Concern(typeof (CastleDynamicProxyBuilder<>))]
public class when_building_a_proxy_to_target_certain_methods_on_a_type : behaves_like_proxy_builder
{
it should_only_intercept_calls_on_the_method_that_was_specified =
() =>
- {
- SomeInterceptor.MethodsCalled.Count().should_be_equal_to(1);
- SomeInterceptor.MethodsCalled.First().Name.should_be_equal_to("OneMethod");
- };
+ {
+ SomeInterceptor.MethodsCalled.Count().should_be_equal_to(1);
+ SomeInterceptor.MethodsCalled.First().Name.should_be_equal_to("OneMethod");
+ };
context c = () => { an_implementation = an<IAnInterface>(); };
because b = () =>
- {
- var constraint = sut.add_interceptor<SomeInterceptor>();
- constraint.intercept_on.OneMethod();
+ {
+ var constraint = sut.add_interceptor<SomeInterceptor>();
+ constraint.intercept_on.OneMethod();
- var proxy = sut.create_proxy_for(() => an_implementation);
- proxy.OneMethod();
- proxy.SecondMethod();
- };
+ var proxy = sut.create_proxy_for(() => an_implementation);
+ proxy.OneMethod();
+ proxy.SecondMethod();
+ };
after_each_observation ae = () =>
- {
- SomeInterceptor.Cleanup();
- AnotherInterceptor.Cleanup();
- };
+ {
+ SomeInterceptor.Cleanup();
+ AnotherInterceptor.Cleanup();
+ };
static IAnInterface an_implementation;
}
- [Concern(typeof (ProxyBuilder<>))]
+ [Concern(typeof (CastleDynamicProxyBuilder<>))]
public class when_proxying_all_calls_on_a_target : behaves_like_proxy_builder
{
it should_intercept_each_call =
() =>
- {
- 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(2).First().Name.should_be_equal_to("region");
- };
+ {
+ 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(2).First().Name.should_be_equal_to("region");
+ };
context c = () => { an_implementation = an<IAnInterface>(); };
because b = () =>
- {
- var constraint = sut.add_interceptor<SomeInterceptor>();
- constraint.intercept_all();
+ {
+ var constraint = sut.add_interceptor<SomeInterceptor>();
+ constraint.intercept_all();
- var proxy = sut.create_proxy_for(() => an_implementation);
- proxy.OneMethod();
- proxy.SecondMethod();
- proxy.region(() => "mo");
- };
+ var proxy = sut.create_proxy_for(() => an_implementation);
+ proxy.OneMethod();
+ proxy.SecondMethod();
+ proxy.region(() => "mo");
+ };
after_each_observation ae = () =>
- {
- SomeInterceptor.Cleanup();
- AnotherInterceptor.Cleanup();
- };
+ {
+ SomeInterceptor.Cleanup();
+ AnotherInterceptor.Cleanup();
+ };
static IAnInterface an_implementation;
}
product/Gorilla.Commons.Infrastructure.ThirdParty/Castle/DynamicProxy/ProxyFactory.cs
@@ -1,48 +1,10 @@
using System;
-using System.Collections.Generic;
-using System.Linq;
using Castle.Core.Interceptor;
-using Castle.DynamicProxy;
-namespace Gorilla.Commons.Infrastructure.Castle.DynamicProxy
+namespace gorilla.commons.infrastructure.thirdparty.Castle.DynamicProxy
{
- public class ProxyFactory : IProxyFactory
+ public interface ProxyFactory
{
- readonly ProxyGenerator generator;
-
- public ProxyFactory() : this(new ProxyGenerator())
- {
- }
-
- public ProxyFactory(ProxyGenerator generator)
- {
- this.generator = generator;
- }
-
- public TypeToProxy create_proxy_for<TypeToProxy>(Func<TypeToProxy> implementation, params IInterceptor[] interceptors)
- {
- return create_proxy_for(lazy_load(implementation), interceptors);
- }
-
- T lazy_load<T>(Func<T> implementation)
- {
- if (typeof (T).IsInterface)
- {
- return generator.CreateInterfaceProxyWithoutTarget<T>(new LazyLoadedInterceptor<T>(implementation));
- }
- return generator.CreateClassProxy<T>(new LazyLoadedInterceptor<T>(implementation));
- }
-
- TypeToProxy create_proxy_for<TypeToProxy>(TypeToProxy implementation,
- IEnumerable<IInterceptor> interceptors)
- {
- if (typeof (TypeToProxy).IsInterface)
- {
- return generator.CreateInterfaceProxyWithTarget<TypeToProxy>(implementation, interceptors.ToArray());
- }
- var list = interceptors.ToList();
- list.Add(new LazyLoadedInterceptor<TypeToProxy>(() => implementation));
- return generator.CreateClassProxy<TypeToProxy>(list.ToArray());
- }
+ TypeToProxy create_proxy_for<TypeToProxy>(Func<TypeToProxy> implementation, params IInterceptor[] interceptors);
}
}
\ No newline at end of file
product/Gorilla.Commons.Infrastructure.ThirdParty/Castle/DynamicProxy/ProxyFactorySpecs.cs
@@ -5,27 +5,27 @@ using developwithpassion.bdd.contexts;
using developwithpassion.bdd.mbunit;
using Gorilla.Commons.Testing;
-namespace Gorilla.Commons.Infrastructure.Castle.DynamicProxy
+namespace gorilla.commons.infrastructure.thirdparty.Castle.DynamicProxy
{
- [Concern(typeof(ProxyFactory))]
- public abstract class behaves_like_proxy_factory : concerns_for<IProxyFactory, ProxyFactory>
+ [Concern(typeof(CastleDynamicProxyFactory))]
+ public abstract class behaves_like_proxy_factory : concerns_for<ProxyFactory, CastleDynamicProxyFactory>
{
- public override IProxyFactory create_sut()
+ public override ProxyFactory create_sut()
{
- return new ProxyFactory();
+ return new CastleDynamicProxyFactory();
}
}
- [Concern(typeof(ProxyFactory))]
+ [Concern(typeof(CastleDynamicProxyFactory))]
public class when_creating_a_proxy_with_a_target : behaves_like_proxy_factory
{
it should_forward_all_calls_to_the_target = () => target.was_told_to(x => x.Open());
it should_return_a_proxy_to_the_target = () =>
- {
- AssertionExtensions.should_not_be_null(result);
- result.GetType().should_not_be_equal_to(target.GetType());
- };
+ {
+ AssertionExtensions.should_not_be_null(result);
+ result.GetType().should_not_be_equal_to(target.GetType());
+ };
it should_allow_the_interceptors_to_intercept_all_calls =
() => AssertionExtensions.should_be_true(interceptor.recieved_call);
@@ -33,18 +33,18 @@ namespace Gorilla.Commons.Infrastructure.Castle.DynamicProxy
context c = () => { target = the_dependency<IDbConnection>(); };
because b = () =>
- {
- interceptor = new TestInterceptor();
- result = sut.create_proxy_for(() => target, interceptor);
- result.Open();
- };
+ {
+ interceptor = new TestInterceptor();
+ result = sut.create_proxy_for(() => target, interceptor);
+ result.Open();
+ };
static IDbConnection target;
static IDbConnection result;
static TestInterceptor interceptor;
}
- [Concern(typeof(ProxyFactory))]
+ [Concern(typeof(CastleDynamicProxyFactory))]
public class when_creating_a_proxy_of_a_target_but_a_call_has_not_been_made_to_the_proxy_yet :
behaves_like_proxy_factory
{
@@ -59,7 +59,7 @@ namespace Gorilla.Commons.Infrastructure.Castle.DynamicProxy
static IDisposable result;
}
- [Concern(typeof(ProxyFactory))]
+ [Concern(typeof(CastleDynamicProxyFactory))]
public class when_creating_a_proxy_of_a_component_that_does_not_implement_an_interface : behaves_like_proxy_factory
{
it should_return_a_proxy = () => AssertionExtensions.should_not_be_null(result);
product/Gorilla.Commons.Infrastructure.ThirdParty/Castle/Windsor/Configuration/ComponentExclusionSpecification.cs
@@ -0,0 +1,9 @@
+using System;
+using gorilla.commons.utility;
+
+namespace gorilla.commons.infrastructure.thirdparty.Castle.Windsor.Configuration
+{
+ public interface ComponentExclusionSpecification : Specification<Type>
+ {
+ }
+}
\ No newline at end of file
product/Gorilla.Commons.Infrastructure.ThirdParty/Castle/Windsor/Configuration/IComponentExclusionSpecification.cs
@@ -1,9 +0,0 @@
-using System;
-using gorilla.commons.utility;
-
-namespace Gorilla.Commons.Infrastructure.Castle.Windsor.Configuration
-{
- public interface IComponentExclusionSpecification : Specification<Type>
- {
- }
-}
\ No newline at end of file
product/Gorilla.Commons.Infrastructure.ThirdParty/Castle/Windsor/WindsorDependencyRegistry.cs
@@ -2,13 +2,15 @@ using System;
using System.Collections.Generic;
using Castle.Core;
using Castle.Windsor;
+using Gorilla.Commons.Infrastructure;
using Gorilla.Commons.Infrastructure.Castle.DynamicProxy;
using Gorilla.Commons.Infrastructure.Container;
+using gorilla.commons.infrastructure.thirdparty.Castle.DynamicProxy;
using gorilla.commons.utility;
-namespace Gorilla.Commons.Infrastructure.Castle.Windsor
+namespace gorilla.commons.infrastructure.thirdparty.Castle.Windsor
{
- public class WindsorDependencyRegistry : IDependencyRegistration, IDependencyRegistry
+ public class WindsorDependencyRegistry : IDependencyRegistration, DependencyRegistry
{
readonly IWindsorContainer underlying_container;
@@ -23,7 +25,7 @@ namespace Gorilla.Commons.Infrastructure.Castle.Windsor
//return underlying_container.Kernel.Resolve<Interface>();
}
- public IEnumerable<Interface> all_the<Interface>()
+ public IEnumerable<Interface> get_all<Interface>()
{
return underlying_container.ResolveAll<Interface>();
}
@@ -58,20 +60,20 @@ namespace Gorilla.Commons.Infrastructure.Castle.Windsor
return "{0}-{1}".formatted_using(interface_type.FullName, implementation_type.FullName);
}
- public void proxy<T>(Configuration<IProxyBuilder<T>> configuration, Func<T> target)
+ public void proxy<T>(Configuration<ProxyBuilder<T>> configuration, Func<T> target)
{
- var builder = new ProxyBuilder<T>();
+ var builder = new CastleDynamicProxyBuilder<T>();
configuration.configure(builder);
singleton(() => builder.create_proxy_for(target));
}
public void proxy<T, Configuration>(Func<T> target)
- where Configuration : Configuration<IProxyBuilder<T>>, new()
+ where Configuration : Configuration<ProxyBuilder<T>>, new()
{
proxy(new Configuration(), target);
}
- public IDependencyRegistry build()
+ public DependencyRegistry build()
{
return this;
}
product/Gorilla.Commons.Infrastructure.ThirdParty/Castle/Windsor/WindsorDependencyRegistrySpecs.cs
@@ -4,10 +4,10 @@ using developwithpassion.bdd.contexts;
using Gorilla.Commons.Infrastructure.Container;
using Gorilla.Commons.Testing;
-namespace Gorilla.Commons.Infrastructure.Castle.Windsor
+namespace gorilla.commons.infrastructure.thirdparty.Castle.Windsor
{
[Concern(typeof (WindsorDependencyRegistry))]
- public abstract class behaves_like_windsor_dependency_registry : concerns_for<IDependencyRegistry, WindsorDependencyRegistry>
+ public abstract class behaves_like_windsor_dependency_registry : concerns_for<DependencyRegistry, WindsorDependencyRegistry>
{
}
@@ -21,11 +21,11 @@ namespace Gorilla.Commons.Infrastructure.Castle.Windsor
it should_not_return_null = () => result.should_not_be_null();
context c = () =>
- {
- var container = the_dependency<IWindsorContainer>();
- var bird = new BlueBird();
- container.is_told_to(x => x.Resolve<IBird>()).it_will_return(bird).Repeat.Any();
- };
+ {
+ var container = the_dependency<IWindsorContainer>();
+ var bird = new BlueBird();
+ container.is_told_to(x => x.Resolve<IBird>()).it_will_return(bird).Repeat.Any();
+ };
because b = () => { result = sut.get_a<IBird>(); };
product/Gorilla.Commons.Infrastructure.ThirdParty/IDependencyRegistration.cs
@@ -5,13 +5,13 @@ using gorilla.commons.utility;
namespace Gorilla.Commons.Infrastructure
{
- public interface IDependencyRegistration : Builder<IDependencyRegistry>
+ public interface IDependencyRegistration : Builder<DependencyRegistry>
{
void singleton<Contract, Implementation>() where Implementation : Contract;
void singleton<Contract>(Func<Contract> instance_of_the_contract);
void transient<Contract, Implementation>() where Implementation : Contract;
void transient(Type contract, Type implementation);
- void proxy<T>(Configuration<IProxyBuilder<T>> configuration, Func<T> target);
- void proxy<T, Configuration>(Func<T> target) where Configuration : Configuration<IProxyBuilder<T>>, new();
+ void proxy<T>(Configuration<ProxyBuilder<T>> configuration, Func<T> target);
+ void proxy<T, Configuration>(Func<T> target) where Configuration : Configuration<ProxyBuilder<T>>, new();
}
}
\ No newline at end of file
product/Gorilla.Commons.Infrastructure.ThirdParty/Gorilla.Commons.Infrastructure.ThirdParty.csproj → product/Gorilla.Commons.Infrastructure.ThirdParty/infrastructure.thirdparty.csproj
@@ -8,8 +8,8 @@
<ProjectGuid>{04DC09B4-5DF9-44A6-8DD1-05941F0D0228}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
- <RootNamespace>Gorilla.Commons.Infrastructure</RootNamespace>
- <AssemblyName>Gorilla.Commons.Infrastructure.ThirdParty</AssemblyName>
+ <RootNamespace>gorilla.commons.infrastructure.thirdparty</RootNamespace>
+ <AssemblyName>gorilla.commons.infrastructure.thirdparty</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
@@ -97,7 +97,7 @@
<Compile Include="IDependencyRegistration.cs" />
<Compile Include="Log4Net\Log4NetLogFactory.cs" />
<Compile Include="Log4Net\Log4NetLogger.cs" />
- <Compile Include="Castle\DynamicProxy\IConstraintSelector.cs" />
+ <Compile Include="Castle\DynamicProxy\ConstraintSelector.cs" />
<Compile Include="Castle\DynamicProxy\IInterceptorConstraint.cs" />
<Compile Include="Castle\DynamicProxy\IInterceptorConstraintFactory.cs" />
<Compile Include="Castle\DynamicProxy\IMethodCallTrackerFactory.cs" />
@@ -107,19 +107,19 @@
<Compile Include="Castle\DynamicProxy\Interceptors\MethodCallTracker.cs" />
<Compile Include="Castle\DynamicProxy\Interceptors\MethodCallTrackerSpecs.cs" />
<Compile Include="Castle\DynamicProxy\Interceptors\SelectiveInterceptor.cs" />
- <Compile Include="Castle\DynamicProxy\IProxyBuilder.cs" />
- <Compile Include="Castle\DynamicProxy\IProxyFactory.cs" />
+ <Compile Include="Castle\DynamicProxy\ProxyBuilder.cs" />
+ <Compile Include="Castle\DynamicProxy\ProxyFactory.cs" />
<Compile Include="Lazy.cs" />
<Compile Include="Castle\DynamicProxy\LazyLoadedInterceptor.cs" />
<Compile Include="LazySpecs.cs" />
- <Compile Include="Castle\DynamicProxy\ProxyBuilder.cs" />
+ <Compile Include="Castle\DynamicProxy\CastleDynamicProxyBuilder.cs" />
<Compile Include="Castle\DynamicProxy\ProxyBuilderSpecs.cs" />
- <Compile Include="Castle\DynamicProxy\ProxyFactory.cs" />
+ <Compile Include="Castle\DynamicProxy\CastleDynamicProxyFactory.cs" />
<Compile Include="Castle\DynamicProxy\ProxyFactorySpecs.cs" />
<Compile Include="Castle\Windsor\Configuration\ApplyLoggingInterceptor.cs" />
<Compile Include="Castle\Windsor\Configuration\ComponentRegistrationConfiguration.cs" />
<Compile Include="Castle\Windsor\Configuration\ConfigureComponentLifestyle.cs" />
- <Compile Include="Castle\Windsor\Configuration\IComponentExclusionSpecification.cs" />
+ <Compile Include="Castle\Windsor\Configuration\ComponentExclusionSpecification.cs" />
<Compile Include="Castle\Windsor\Configuration\LogComponent.cs" />
<Compile Include="Castle\Windsor\Configuration\LoggingInterceptor.cs" />
<Compile Include="Castle\Windsor\Configuration\RegisterComponentContract.cs" />
@@ -128,13 +128,13 @@
<Compile Include="Castle\Windsor\WindsorDependencyRegistrySpecs.cs" />
</ItemGroup>
<ItemGroup>
- <ProjectReference Include="..\Gorilla.Commons.Infrastructure\Gorilla.Commons.Infrastructure.csproj">
+ <ProjectReference Include="..\Gorilla.Commons.Infrastructure\infrastructure.csproj">
<Project>{AA5EEED9-4531-45F7-AFCD-AD9717D2E405}</Project>
- <Name>Gorilla.Commons.Infrastructure</Name>
+ <Name>infrastructure</Name>
</ProjectReference>
- <ProjectReference Include="..\Gorilla.Commons.Testing\Gorilla.Commons.Testing.csproj">
+ <ProjectReference Include="..\Gorilla.Commons.Testing\test.helpers.csproj">
<Project>{44E65096-9657-4716-90F8-4535BABE8039}</Project>
- <Name>Gorilla.Commons.Testing</Name>
+ <Name>test.helpers</Name>
</ProjectReference>
<ProjectReference Include="..\Gorilla.Commons.Utility\utility.csproj">
<Project>{DD8FD29E-7424-415C-9BA3-7D9F6ECBA161}</Project>
product/Gorilla.Commons.Infrastructure.ThirdParty/LazySpecs.cs
@@ -9,13 +9,13 @@ namespace Gorilla.Commons.Infrastructure
{
context c = () =>
{
- test_container = dependency<IDependencyRegistry>();
+ test_container = dependency<DependencyRegistry>();
Resolve.initialize_with(test_container);
};
after_each_observation a = () => Resolve.initialize_with(null);
- protected static IDependencyRegistry test_container;
+ protected static DependencyRegistry test_container;
}
[Concern(typeof (Lazy))]
product/Gorilla.Commons.Testing/Gorilla.Commons.Testing.csproj → product/Gorilla.Commons.Testing/test.helpers.csproj
File renamed without changes
product/Gorilla.Commons.Utility/utility.csproj
@@ -128,9 +128,9 @@
<Compile Include="Year.cs" />
</ItemGroup>
<ItemGroup>
- <ProjectReference Include="..\Gorilla.Commons.Testing\Gorilla.Commons.Testing.csproj">
+ <ProjectReference Include="..\Gorilla.Commons.Testing\test.helpers.csproj">
<Project>{44E65096-9657-4716-90F8-4535BABE8039}</Project>
- <Name>Gorilla.Commons.Testing</Name>
+ <Name>test.helpers</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
solution.sln
@@ -1,13 +1,13 @@
Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gorilla.Commons.Testing", "product\Gorilla.Commons.Testing\Gorilla.Commons.Testing.csproj", "{44E65096-9657-4716-90F8-4535BABE8039}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "test.helpers", "product\Gorilla.Commons.Testing\test.helpers.csproj", "{44E65096-9657-4716-90F8-4535BABE8039}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gorilla.Commons.Infrastructure", "product\Gorilla.Commons.Infrastructure\Gorilla.Commons.Infrastructure.csproj", "{AA5EEED9-4531-45F7-AFCD-AD9717D2E405}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "infrastructure", "product\Gorilla.Commons.Infrastructure\infrastructure.csproj", "{AA5EEED9-4531-45F7-AFCD-AD9717D2E405}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gorilla.Commons.Infrastructure.ThirdParty", "product\Gorilla.Commons.Infrastructure.ThirdParty\Gorilla.Commons.Infrastructure.ThirdParty.csproj", "{04DC09B4-5DF9-44A6-8DD1-05941F0D0228}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "infrastructure.thirdparty", "product\Gorilla.Commons.Infrastructure.ThirdParty\infrastructure.thirdparty.csproj", "{04DC09B4-5DF9-44A6-8DD1-05941F0D0228}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gorilla.Commons.Build", "build\Gorilla.Commons.Build.csproj", "{B8505B10-85C7-45F4-B039-D364DD556D7D}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "build", "build\build.csproj", "{B8505B10-85C7-45F4-B039-D364DD556D7D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "utility", "product\Gorilla.Commons.Utility\utility.csproj", "{DD8FD29E-7424-415C-9BA3-7D9F6ECBA161}"
EndProject