Commit 6929719
Changed files (147)
build
config
product
Gorilla.Commons.Infrastructure
Logging
Registries
Gorilla.Commons.Infrastructure.ThirdParty
Castle
DynamicProxy
Interceptors
Log4Net
Gorilla.Commons.Utility
Core
Extensions
Gorilla.Commons.Windows.Forms
Gorilla.Commons.Windows.Forms.ThirdParty
build/config/bootstrap.xml
@@ -0,0 +1,30 @@
+<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+
+ <PropertyGroup>
+ <AppFileFullPath>D:\development\mokhan\gorilla.commons\build\installation\gorilla.commons.dll.application</AppFileFullPath>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <BootstrapperFile Include="Microsoft.Net.Framework.3.5">
+ <ProductName>.NET Framework 3.5</ProductName>
+ </BootstrapperFile>
+ <BootstrapperFile Include="Microsoft.Windows.Installer.3.1">
+ <ProductName>Windows Installer 3.1</ProductName>
+ </BootstrapperFile>
+ </ItemGroup>
+
+ <Target Name="Bootstrapper">
+ <GenerateBootstrapper
+ ApplicationFile="gorilla.commons.infrastructure.thirdparty.dll.application"
+ ApplicationName="My Money by mOKhan.ca"
+ ApplicationUrl="http://mokhan.ca/GorillaCommons/"
+ BootstrapperItems="@(BootstrapperFile)"
+ ComponentsLocation="HomeSite"
+ Culture="en"
+ FallbackCulture="en-US"
+ CopyComponents="True"
+ Validate="True"
+ OutputPath="D:\development\mokhan\gorilla.commons\build\installation" />
+ </Target>
+
+</Project>
\ No newline at end of file
build/Empty.cs
@@ -1,7 +1,4 @@
-namespace MyMoney.Build
+namespace Gorilla.Commons.Build
{
- public class Empty
- {
-
- }
+ public class Empty {}
}
\ No newline at end of file
product/Gorilla.Commons.Infrastructure/Container/DependencyResolutionException.cs
@@ -1,5 +1,5 @@
using System;
-using Gorilla.Commons.Utility.Extensions;
+using gorilla.commons.utility;
namespace Gorilla.Commons.Infrastructure.Container
{
product/Gorilla.Commons.Infrastructure/Container/ResolveSpecs.cs
@@ -1,7 +1,7 @@
using System;
using developwithpassion.bdd.contexts;
using Gorilla.Commons.Testing;
-using Gorilla.Commons.Utility.Core;
+using gorilla.commons.utility;
namespace Gorilla.Commons.Infrastructure.Container
{
@@ -16,23 +16,23 @@ namespace Gorilla.Commons.Infrastructure.Container
context c = () =>
{
registry = an<IDependencyRegistry>();
- presenter = an<ICommand>();
- registry.is_told_to(x => x.get_a<ICommand>()).it_will_return(presenter);
+ presenter = an<Command>();
+ registry.is_told_to(x => x.get_a<Command>()).it_will_return(presenter);
Resolve.initialize_with(registry);
};
- because b = () => { result = Resolve.the<ICommand>(); };
+ because b = () => { result = Resolve.the<Command>(); };
it should_leverage_the_underlying_container_it_was_initialized_with =
- () => registry.was_told_to(x => x.get_a<ICommand>());
+ () => registry.was_told_to(x => x.get_a<Command>());
it should_return_the_resolved_dependency = () => result.should_be_equal_to(presenter);
after_each_observation a = () => Resolve.initialize_with(null);
static IDependencyRegistry registry;
- static ICommand result;
- static ICommand presenter;
+ static Command result;
+ static Command presenter;
}
[Concern(typeof(Resolve))]
@@ -41,16 +41,16 @@ namespace Gorilla.Commons.Infrastructure.Container
context c = () =>
{
registry = an<IDependencyRegistry>();
- registry.is_told_to(x => x.get_a<ICommand>()).it_will_throw(new Exception());
+ registry.is_told_to(x => x.get_a<Command>()).it_will_throw(new Exception());
Resolve.initialize_with(registry);
};
- because b = () => { the_call = call.to(() => Resolve.the<ICommand>()); };
+ because b = () => { the_call = call.to(() => Resolve.the<Command>()); };
after_each_observation a = () => Resolve.initialize_with(null);
it should_throw_a_dependency_resolution_exception =
- () => the_call.should_have_thrown<DependencyResolutionException<ICommand>>();
+ () => the_call.should_have_thrown<DependencyResolutionException<Command>>();
static IDependencyRegistry registry;
static Action the_call;
product/Gorilla.Commons.Infrastructure/Logging/ILogFactory.cs
@@ -1,9 +0,0 @@
-using System;
-
-namespace Gorilla.Commons.Infrastructure.Logging
-{
- public interface ILogFactory
- {
- ILogger create_for(Type type_to_create_logger_for);
- }
-}
\ No newline at end of file
product/Gorilla.Commons.Infrastructure/Logging/Log.cs
@@ -1,21 +1,20 @@
using System;
using Gorilla.Commons.Infrastructure.Container;
-using Gorilla.Commons.Infrastructure.Logging.Console;
namespace Gorilla.Commons.Infrastructure.Logging
{
static public class Log
{
- static public ILogger For<T>(T item_to_create_logger_for)
+ static public Logger For<T>(T item_to_create_logger_for)
{
return For(typeof (T));
}
- static public ILogger For(Type type_to_create_a_logger_for)
+ static public Logger For(Type type_to_create_a_logger_for)
{
try
{
- return Resolve.the<ILogFactory>().create_for(type_to_create_a_logger_for);
+ return Resolve.the<LogFactory>().create_for(type_to_create_a_logger_for);
}
catch
{
product/Gorilla.Commons.Infrastructure/Logging/LogFactory.cs
@@ -0,0 +1,9 @@
+using System;
+
+namespace Gorilla.Commons.Infrastructure.Logging
+{
+ public interface LogFactory
+ {
+ Logger create_for(Type type_to_create_logger_for);
+ }
+}
\ No newline at end of file
product/Gorilla.Commons.Infrastructure/Logging/ILoggable.cs → product/Gorilla.Commons.Infrastructure/Logging/Loggable.cs
@@ -1,6 +1,6 @@
namespace Gorilla.Commons.Infrastructure.Logging
{
- public interface ILoggable
+ public interface Loggable
{
}
product/Gorilla.Commons.Infrastructure/Logging/ILogger.cs → product/Gorilla.Commons.Infrastructure/Logging/Logger.cs
@@ -2,7 +2,7 @@ using System;
namespace Gorilla.Commons.Infrastructure.Logging
{
- public interface ILogger
+ public interface Logger
{
void informational(string formatted_string, params object[] arguments);
void debug(string formatted_string, params object[] arguments);
product/Gorilla.Commons.Infrastructure/Logging/LoggingExtensions.cs
@@ -4,7 +4,7 @@ namespace Gorilla.Commons.Infrastructure.Logging
{
public static class LoggingExtensions
{
- public static ILogger log<T>(this T item_to_log)
+ public static Logger log<T>(this T item_to_log)
{
return Log.For(item_to_log);
}
product/Gorilla.Commons.Infrastructure/Logging/LogSpecs.cs
@@ -12,10 +12,10 @@ namespace Gorilla.Commons.Infrastructure.Logging
context c =
() =>
{
- var factory = an<ILogFactory>();
+ var factory = an<LogFactory>();
var registry = an<IDependencyRegistry>();
- logger = an<ILogger>();
- registry.is_told_to(x => x.get_a<ILogFactory>()).it_will_return(factory);
+ 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);
Resolve.initialize_with(registry);
@@ -25,7 +25,7 @@ namespace Gorilla.Commons.Infrastructure.Logging
after_each_observation a = () => Resolve.initialize_with(null);
- static ILogger result;
- static ILogger logger;
+ static Logger result;
+ static Logger logger;
}
}
\ No newline at end of file
product/Gorilla.Commons.Infrastructure/Logging/TextLogger.cs
@@ -1,11 +1,11 @@
using System;
using System.IO;
using System.Threading;
-using Gorilla.Commons.Utility.Extensions;
+using gorilla.commons.utility;
-namespace Gorilla.Commons.Infrastructure.Logging.Console
+namespace Gorilla.Commons.Infrastructure.Logging
{
- public class TextLogger : ILogger
+ public class TextLogger : Logger
{
readonly TextWriter writer;
product/Gorilla.Commons.Infrastructure/Proxies/MethodCallInvocation.cs
@@ -1,7 +1,7 @@
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.Remoting.Messaging;
-using Gorilla.Commons.Utility.Extensions;
+using gorilla.commons.utility;
namespace Gorilla.Commons.Infrastructure.Proxies
{
product/Gorilla.Commons.Infrastructure/Proxies/ProxyFactorySpecs.cs
@@ -5,54 +5,56 @@ namespace Gorilla.Commons.Infrastructure.Proxies
{
public class ProxyFactorySpecs
{
- }
-
- [Concern(typeof(ProxyFactory))]
- public class when_proxying_a_class_with_interceptors_applied : concerns
- {
- context c = () =>
- {
- interceptors = new MyNameIsSlimShadyInterceptor();
- marshal_mathers = new Person("marshall mathers");
- };
-
- because b =
- () => { some_celebrity = ProxyFactory.create<IPerson>(marshal_mathers, interceptors); };
-
- it should_all_each_interceptor_to_intercept_the_invocation =
- () => some_celebrity.what_is_your_name().should_be_equal_to("slim shady");
-
- static Person marshal_mathers;
- static IPerson some_celebrity;
- static IInterceptor interceptors;
- }
-
- public interface IPerson
- {
- string what_is_your_name();
- }
-
- public class Person : IPerson
- {
- readonly string my_name;
+ [Concern(typeof (ProxyFactory))]
+ public class when_proxying_a_class_with_interceptors_applied : concerns
+ {
+ context c = () =>
+ {
+ interceptors = new MyNameIsSlimShadyInterceptor();
+ marshal_mathers = new Person("marshall mathers");
+ };
+
+ because b =
+ () =>
+ {
+ some_celebrity = ProxyFactory.create<IPerson>(marshal_mathers, interceptors);
+ };
+
+ it should_all_each_interceptor_to_intercept_the_invocation =
+ () => some_celebrity.what_is_your_name().should_be_equal_to("slim shady");
+
+ static Person marshal_mathers;
+ static IPerson some_celebrity;
+ static IInterceptor interceptors;
+ }
- public Person(string my_name)
+ public interface IPerson
{
- this.my_name = my_name;
+ string what_is_your_name();
}
- public string what_is_your_name()
+ public class Person : IPerson
{
- return my_name;
+ readonly string my_name;
+
+ public Person(string my_name)
+ {
+ this.my_name = my_name;
+ }
+
+ public string what_is_your_name()
+ {
+ return my_name;
+ }
}
- }
- public class MyNameIsSlimShadyInterceptor : IInterceptor
- {
- public void intercept(IInvocation invocation)
+ public class MyNameIsSlimShadyInterceptor : IInterceptor
{
- invocation.proceed();
- invocation.return_value = "slim shady";
+ public void intercept(IInvocation invocation)
+ {
+ invocation.proceed();
+ invocation.return_value = "slim shady";
+ }
}
}
}
\ No newline at end of file
product/Gorilla.Commons.Infrastructure/Proxies/RemotingProxyFactory.cs
@@ -1,7 +1,7 @@
using System.Collections.Generic;
using System.Runtime.Remoting.Messaging;
using System.Runtime.Remoting.Proxies;
-using Gorilla.Commons.Utility.Extensions;
+using gorilla.commons.utility;
namespace Gorilla.Commons.Infrastructure.Proxies
{
product/Gorilla.Commons.Infrastructure/Registries/DefaultRegistry.cs
@@ -1,10 +1,11 @@
+using System.Collections;
using System.Collections.Generic;
using Gorilla.Commons.Infrastructure.Container;
-using Gorilla.Commons.Utility.Core;
+using gorilla.commons.utility;
namespace Gorilla.Commons.Infrastructure.Registries
{
- public class DefaultRegistry<T> : IRegistry<T>
+ public class DefaultRegistry<T> : Registry<T>
{
readonly IDependencyRegistry registry;
@@ -17,5 +18,15 @@ namespace Gorilla.Commons.Infrastructure.Registries
{
return registry.all_the<T>();
}
+
+ public IEnumerator<T> GetEnumerator()
+ {
+ return all().GetEnumerator();
+ }
+
+ IEnumerator IEnumerable.GetEnumerator()
+ {
+ return GetEnumerator();
+ }
}
}
\ No newline at end of file
product/Gorilla.Commons.Infrastructure/Registries/DefaultRegistrySpecs.cs
@@ -2,13 +2,13 @@ using System.Collections.Generic;
using developwithpassion.bdd.contexts;
using Gorilla.Commons.Infrastructure.Container;
using Gorilla.Commons.Testing;
-using Gorilla.Commons.Utility.Core;
+using gorilla.commons.utility;
namespace Gorilla.Commons.Infrastructure.Registries
{
[Concern(typeof (DefaultRegistry<int>))]
public class when_retrieving_all_the_items_from_the_default_repository :
- concerns_for<IRegistry<int>, DefaultRegistry<int>>
+ 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>());
@@ -22,7 +22,7 @@ namespace Gorilla.Commons.Infrastructure.Registries
registry.is_told_to(r => r.all_the<int>()).it_will_return(items_to_return);
};
- public override IRegistry<int> create_sut()
+ public override Registry<int> create_sut()
{
return new DefaultRegistry<int>(registry);
}
product/Gorilla.Commons.Infrastructure/Gorilla.Commons.Infrastructure.csproj
@@ -74,9 +74,9 @@
<Compile Include="FileSystem\ApplicationFile.cs" />
<Compile Include="FileSystem\IFile.cs" />
<Compile Include="Logging\TextLogger.cs" />
- <Compile Include="Logging\ILogFactory.cs" />
- <Compile Include="Logging\ILoggable.cs" />
- <Compile Include="Logging\ILogger.cs" />
+ <Compile Include="Logging\LogFactory.cs" />
+ <Compile Include="Logging\Loggable.cs" />
+ <Compile Include="Logging\Logger.cs" />
<Compile Include="Logging\Log.cs" />
<Compile Include="Logging\LoggingExtensions.cs" />
<Compile Include="Logging\LogSpecs.cs" />
@@ -98,9 +98,9 @@
<Project>{44E65096-9657-4716-90F8-4535BABE8039}</Project>
<Name>Gorilla.Commons.Testing</Name>
</ProjectReference>
- <ProjectReference Include="..\Gorilla.Commons.Utility\Gorilla.Commons.Utility.csproj">
+ <ProjectReference Include="..\Gorilla.Commons.Utility\utility.csproj">
<Project>{DD8FD29E-7424-415C-9BA3-7D9F6ECBA161}</Project>
- <Name>Gorilla.Commons.Utility</Name>
+ <Name>utility</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
product/Gorilla.Commons.Infrastructure.ThirdParty/Autofac/AutofacDependencyRegistryBuilder.cs
@@ -5,8 +5,7 @@ using Autofac.Modules;
using AutofacContrib.DynamicProxy2;
using Gorilla.Commons.Infrastructure.Castle.DynamicProxy;
using Gorilla.Commons.Infrastructure.Container;
-using Gorilla.Commons.Utility.Core;
-using Gorilla.Commons.Utility.Extensions;
+using gorilla.commons.utility;
namespace Gorilla.Commons.Infrastructure.Autofac
{
@@ -52,7 +51,7 @@ namespace Gorilla.Commons.Infrastructure.Autofac
builder.Register(implementation).As(contract).FactoryScoped();
}
- public void proxy<T>(IConfiguration<IProxyBuilder<T>> configuration, Func<T> target)
+ public void proxy<T>(Configuration<IProxyBuilder<T>> configuration, Func<T> target)
{
var proxy_builder = new ProxyBuilder<T>();
configuration.configure(proxy_builder);
@@ -60,7 +59,7 @@ namespace Gorilla.Commons.Infrastructure.Autofac
}
public void proxy<T, Configuration>(Func<T> target)
- where Configuration : IConfiguration<IProxyBuilder<T>>, new()
+ where Configuration : Configuration<IProxyBuilder<T>>, new()
{
proxy(new Configuration(), target);
}
product/Gorilla.Commons.Infrastructure.ThirdParty/Castle/DynamicProxy/Interceptors/MethodCallTracker.cs
@@ -1,6 +1,6 @@
using System.Collections.Generic;
using Castle.Core.Interceptor;
-using Gorilla.Commons.Utility.Extensions;
+using gorilla.commons.utility;
namespace Gorilla.Commons.Infrastructure.Castle.DynamicProxy.Interceptors
{
product/Gorilla.Commons.Infrastructure.ThirdParty/Castle/DynamicProxy/Interceptors/SynchronizedInterceptor.cs
@@ -1,7 +1,7 @@
using System;
using System.ComponentModel;
using Castle.Core.Interceptor;
-using Gorilla.Commons.Utility.Extensions;
+using gorilla.commons.utility;
namespace Gorilla.Commons.Infrastructure.Castle.DynamicProxy.Interceptors
{
product/Gorilla.Commons.Infrastructure.ThirdParty/Castle/Windsor/Configuration/ApplyLoggingInterceptor.cs
@@ -9,7 +9,7 @@ namespace Gorilla.Commons.Infrastructure.Castle.Windsor.Configuration
public void configure(ComponentRegistration registration)
{
var implementation = registration.Implementation;
- if (typeof (ILoggable).IsAssignableFrom(implementation))
+ if (typeof (Loggable).IsAssignableFrom(implementation))
{
registration
.Interceptors(new InterceptorReference(typeof (ILoggingInterceptor)))
product/Gorilla.Commons.Infrastructure.ThirdParty/Castle/Windsor/Configuration/ComponentRegistrationConfiguration.cs
@@ -1,10 +1,9 @@
using Castle.MicroKernel.Registration;
-using Gorilla.Commons.Utility.Core;
-using Gorilla.Commons.Utility.Extensions;
+using gorilla.commons.utility;
namespace Gorilla.Commons.Infrastructure.Castle.Windsor.Configuration
{
- public interface IRegistrationConfiguration : IConfiguration<ComponentRegistration>
+ public interface IRegistrationConfiguration : Configuration<ComponentRegistration>
{
}
@@ -12,8 +11,8 @@ namespace Gorilla.Commons.Infrastructure.Castle.Windsor.Configuration
{
public void configure(ComponentRegistration registration)
{
- ConfigurationExtensions.then(new RegisterComponentContract()
- .then(new ConfigureComponentLifestyle()), new ApplyLoggingInterceptor())
+ new RegisterComponentContract()
+ .then(new ConfigureComponentLifestyle()).then(new ApplyLoggingInterceptor())
//.then(new LogComponent())
.configure(registration);
}
product/Gorilla.Commons.Infrastructure.ThirdParty/Castle/Windsor/Configuration/IComponentExclusionSpecification.cs
@@ -1,9 +1,9 @@
using System;
-using Gorilla.Commons.Utility.Core;
+using gorilla.commons.utility;
namespace Gorilla.Commons.Infrastructure.Castle.Windsor.Configuration
{
- public interface IComponentExclusionSpecification : ISpecification<Type>
+ public interface IComponentExclusionSpecification : Specification<Type>
{
}
}
\ No newline at end of file
product/Gorilla.Commons.Infrastructure.ThirdParty/Castle/Windsor/WindsorContainerFactory.cs
@@ -1,9 +1,9 @@
using Castle.Windsor;
-using Gorilla.Commons.Utility.Core;
+using gorilla.commons.utility;
namespace Gorilla.Commons.Infrastructure.Castle.Windsor
{
- public interface IWindsorContainerFactory : IFactory<IWindsorContainer>
+ public interface IWindsorContainerFactory : Factory<IWindsorContainer>
{
}
product/Gorilla.Commons.Infrastructure.ThirdParty/Castle/Windsor/WindsorDependencyRegistry.cs
@@ -4,8 +4,7 @@ using Castle.Core;
using Castle.Windsor;
using Gorilla.Commons.Infrastructure.Castle.DynamicProxy;
using Gorilla.Commons.Infrastructure.Container;
-using Gorilla.Commons.Utility.Core;
-using Gorilla.Commons.Utility.Extensions;
+using gorilla.commons.utility;
namespace Gorilla.Commons.Infrastructure.Castle.Windsor
{
@@ -59,7 +58,7 @@ namespace Gorilla.Commons.Infrastructure.Castle.Windsor
return "{0}-{1}".formatted_using(interface_type.FullName, implementation_type.FullName);
}
- public void proxy<T>(IConfiguration<IProxyBuilder<T>> configuration, Func<T> target)
+ public void proxy<T>(Configuration<IProxyBuilder<T>> configuration, Func<T> target)
{
var builder = new ProxyBuilder<T>();
configuration.configure(builder);
@@ -67,7 +66,7 @@ namespace Gorilla.Commons.Infrastructure.Castle.Windsor
}
public void proxy<T, Configuration>(Func<T> target)
- where Configuration : IConfiguration<IProxyBuilder<T>>, new()
+ where Configuration : Configuration<IProxyBuilder<T>>, new()
{
proxy(new Configuration(), target);
}
product/Gorilla.Commons.Infrastructure.ThirdParty/Log4Net/Log4NetLogFactory.cs
@@ -7,14 +7,14 @@ using log4net.Config;
namespace Gorilla.Commons.Infrastructure.Log4Net
{
- public class Log4NetLogFactory : ILogFactory
+ public class Log4NetLogFactory : LogFactory
{
public Log4NetLogFactory()
{
XmlConfigurator.Configure(PathToConfigFile());
}
- public ILogger create_for(Type type_to_create_logger_for)
+ public Logger create_for(Type type_to_create_logger_for)
{
return new Log4NetLogger(LogManager.GetLogger(type_to_create_logger_for));
}
product/Gorilla.Commons.Infrastructure.ThirdParty/Log4Net/Log4NetLogger.cs
@@ -4,7 +4,7 @@ using log4net;
namespace Gorilla.Commons.Infrastructure.Log4Net
{
- public class Log4NetLogger : ILogger
+ public class Log4NetLogger : Logger
{
readonly ILog log;
product/Gorilla.Commons.Infrastructure.ThirdParty/Gorilla.Commons.Infrastructure.ThirdParty.csproj
@@ -136,9 +136,9 @@
<Project>{44E65096-9657-4716-90F8-4535BABE8039}</Project>
<Name>Gorilla.Commons.Testing</Name>
</ProjectReference>
- <ProjectReference Include="..\Gorilla.Commons.Utility\Gorilla.Commons.Utility.csproj">
+ <ProjectReference Include="..\Gorilla.Commons.Utility\utility.csproj">
<Project>{DD8FD29E-7424-415C-9BA3-7D9F6ECBA161}</Project>
- <Name>Gorilla.Commons.Utility</Name>
+ <Name>utility</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
product/Gorilla.Commons.Infrastructure.ThirdParty/IDependencyRegistration.cs
@@ -1,17 +1,17 @@
using System;
using Gorilla.Commons.Infrastructure.Castle.DynamicProxy;
using Gorilla.Commons.Infrastructure.Container;
-using Gorilla.Commons.Utility.Core;
+using gorilla.commons.utility;
namespace Gorilla.Commons.Infrastructure
{
- public interface IDependencyRegistration : IBuilder<IDependencyRegistry>
+ public interface IDependencyRegistration : Builder<IDependencyRegistry>
{
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>(IConfiguration<IProxyBuilder<T>> configuration, Func<T> target);
- void proxy<T, Configuration>(Func<T> target) where Configuration : IConfiguration<IProxyBuilder<T>>, new();
+ void proxy<T>(Configuration<IProxyBuilder<T>> configuration, Func<T> target);
+ void proxy<T, Configuration>(Func<T> target) where Configuration : Configuration<IProxyBuilder<T>>, new();
}
}
\ No newline at end of file
product/Gorilla.Commons.Infrastructure.ThirdParty/Lazy.cs
@@ -3,7 +3,7 @@ using Castle.Core.Interceptor;
using Castle.DynamicProxy;
using Gorilla.Commons.Infrastructure.Castle.DynamicProxy;
using Gorilla.Commons.Infrastructure.Container;
-using Gorilla.Commons.Utility.Extensions;
+using gorilla.commons.utility;
namespace Gorilla.Commons.Infrastructure
{
product/Gorilla.Commons.Infrastructure.ThirdParty/LazySpecs.cs
@@ -65,7 +65,7 @@ namespace Gorilla.Commons.Infrastructure
public class when_calling_different_methods_on_an_proxied_object : behaves_like_a_lazy_loaded_object
{
it should_only_load_the_object_once =
- () => MockingExtensions.was_told_to(test_container, x => x.get_a<ITargetObject>()).only_once();
+ () => test_container.was_told_to(x => x.get_a<ITargetObject>()).only_once();
context c = () =>
{
@@ -155,7 +155,7 @@ namespace Gorilla.Commons.Infrastructure
public class when_calling_a_generic_method_on_a_proxied_object : behaves_like_a_lazy_loaded_object
{
it should_forward_the_call_to_the_target =
- () => MockingExtensions.was_told_to(target, x => x.ValueReturningMethodWithAnArgument("blah"));
+ () => target.was_told_to(x => x.ValueReturningMethodWithAnArgument("blah"));
it should_return_the_correct_result = () => result.should_be_equal_to("hooray");
product/Gorilla.Commons.Utility/Core/ActionCommand.cs
@@ -1,24 +0,0 @@
-using System;
-using System.Linq.Expressions;
-
-namespace Gorilla.Commons.Utility.Core
-{
- public class ActionCommand : ICommand
- {
- readonly Action action;
-
- public ActionCommand(Expression<Action> action) : this(action.Compile())
- {
- }
-
- public ActionCommand(Action action)
- {
- this.action = action;
- }
-
- public void run()
- {
- action();
- }
- }
-}
\ No newline at end of file
product/Gorilla.Commons.Utility/Core/AndSpecification.cs
@@ -1,19 +0,0 @@
-namespace Gorilla.Commons.Utility.Core
-{
- public class AndSpecification<T> : ISpecification<T>
- {
- readonly ISpecification<T> left;
- readonly ISpecification<T> right;
-
- public AndSpecification(ISpecification<T> left, ISpecification<T> right)
- {
- this.left = left;
- this.right = right;
- }
-
- public bool is_satisfied_by(T item)
- {
- return left.is_satisfied_by(item) && right.is_satisfied_by(item);
- }
- }
-}
\ No newline at end of file
product/Gorilla.Commons.Utility/Core/ChainedCommand.cs
@@ -1,20 +0,0 @@
-namespace Gorilla.Commons.Utility.Core
-{
- public class ChainedCommand : ICommand
- {
- private readonly ICommand left;
- private readonly ICommand right;
-
- public ChainedCommand(ICommand left, ICommand right)
- {
- this.left = left;
- this.right = right;
- }
-
- public void run()
- {
- left.run();
- right.run();
- }
- }
-}
\ No newline at end of file
product/Gorilla.Commons.Utility/Core/ChainedConfiguration.cs
@@ -1,20 +0,0 @@
-namespace Gorilla.Commons.Utility.Core
-{
- public class ChainedConfiguration<T> : IConfiguration<T>
- {
- readonly IConfiguration<T> first;
- readonly IConfiguration<T> second;
-
- public ChainedConfiguration(IConfiguration<T> first, IConfiguration<T> second)
- {
- this.first = first;
- this.second = second;
- }
-
- public void configure(T item)
- {
- first.configure(item);
- second.configure(item);
- }
- }
-}
\ No newline at end of file
product/Gorilla.Commons.Utility/Core/ChainedMapper.cs
@@ -1,19 +0,0 @@
-namespace Gorilla.Commons.Utility.Core
-{
- public class ChainedMapper<Left, Middle, Right> : IMapper<Left, Right>
- {
- private readonly IMapper<Left, Middle> left;
- private readonly IMapper<Middle, Right> right;
-
- public ChainedMapper(IMapper<Left, Middle> left, IMapper<Middle, Right> right)
- {
- this.left = left;
- this.right = right;
- }
-
- public Right map_from(Left item)
- {
- return right.map_from(left.map_from(item));
- }
- }
-}
\ No newline at end of file
product/Gorilla.Commons.Utility/Core/ComponentFactory.cs
@@ -1,14 +0,0 @@
-namespace Gorilla.Commons.Utility.Core
-{
- public interface IComponentFactory<T> : IFactory<T> where T : new()
- {
- }
-
- public class ComponentFactory<T> : IComponentFactory<T> where T : new()
- {
- public T create()
- {
- return new T();
- }
- }
-}
\ No newline at end of file
product/Gorilla.Commons.Utility/Core/DisposableCommand.cs
@@ -1,24 +0,0 @@
-using System;
-using MoMoney.Utility.Core;
-
-namespace Gorilla.Commons.Utility.Core
-{
- public class DisposableCommand : IDisposableCommand
- {
- readonly Action action;
-
- public DisposableCommand(Action action)
- {
- this.action = action;
- }
-
- public void run()
- {
- action();
- }
-
- public void Dispose()
- {
- }
- }
-}
\ No newline at end of file
product/Gorilla.Commons.Utility/Core/EmptyCallback.cs
@@ -1,13 +0,0 @@
-namespace Gorilla.Commons.Utility.Core
-{
- public class EmptyCallback<T> : ICallback<T>, ICallback
- {
- public void run(T item)
- {
- }
-
- public void run()
- {
- }
- }
-}
\ No newline at end of file
product/Gorilla.Commons.Utility/Core/EmptyCommand.cs
@@ -1,9 +0,0 @@
-namespace Gorilla.Commons.Utility.Core
-{
- public class EmptyCommand : ICommand
- {
- public void run()
- {
- }
- }
-}
\ No newline at end of file
product/Gorilla.Commons.Utility/Core/Factory.cs
@@ -1,6 +0,0 @@
-namespace Gorilla.Commons.Utility.Core
-{
- public delegate Out Factory<In, Out>(In input);
-
- public delegate Out Factory<Out>();
-}
\ No newline at end of file
product/Gorilla.Commons.Utility/Core/IBuilder.cs
@@ -1,7 +0,0 @@
-namespace Gorilla.Commons.Utility.Core
-{
- public interface IBuilder<T>
- {
- T build();
- }
-}
\ No newline at end of file
product/Gorilla.Commons.Utility/Core/ICallback.cs
@@ -1,10 +0,0 @@
-namespace Gorilla.Commons.Utility.Core
-{
- public interface ICallback : ICommand
- {
- }
-
- public interface ICallback<T> : IParameterizedCommand<T>
- {
- }
-}
\ No newline at end of file
product/Gorilla.Commons.Utility/Core/ICallbackCommand.cs
@@ -1,6 +0,0 @@
-namespace Gorilla.Commons.Utility.Core
-{
- public interface ICallbackCommand<T> : IParameterizedCommand<ICallback<T>>
- {
- }
-}
\ No newline at end of file
product/Gorilla.Commons.Utility/Core/ICommand.cs
@@ -1,7 +0,0 @@
-namespace Gorilla.Commons.Utility.Core
-{
- public interface ICommand
- {
- void run();
- }
-}
\ No newline at end of file
product/Gorilla.Commons.Utility/Core/IConfiguration.cs
@@ -1,7 +0,0 @@
-namespace Gorilla.Commons.Utility.Core
-{
- public interface IConfiguration<T>
- {
- void configure(T item);
- }
-}
\ No newline at end of file
product/Gorilla.Commons.Utility/Core/IDisposableCommand.cs
@@ -1,8 +0,0 @@
-using System;
-using Gorilla.Commons.Utility.Core;
-
-namespace MoMoney.Utility.Core
-{
- public interface IDisposableCommand : ICommand, IDisposable
- {}
-}
\ No newline at end of file
product/Gorilla.Commons.Utility/Core/IFactory.cs
@@ -1,7 +0,0 @@
-namespace Gorilla.Commons.Utility.Core
-{
- public interface IFactory<T>
- {
- T create();
- }
-}
\ No newline at end of file
product/Gorilla.Commons.Utility/Core/IIdentifiable.cs
@@ -1,7 +0,0 @@
-namespace Gorilla.Commons.Utility.Core
-{
- public interface IIdentifiable<T>
- {
- Id<T> id { get; }
- }
-}
\ No newline at end of file
product/Gorilla.Commons.Utility/Core/IImport.cs
@@ -1,7 +0,0 @@
-namespace Gorilla.Commons.Utility.Core
-{
- public interface IImport<T>
- {
- void import(T item);
- }
-}
\ No newline at end of file
product/Gorilla.Commons.Utility/Core/IMapper.cs
@@ -1,7 +0,0 @@
-namespace Gorilla.Commons.Utility.Core
-{
- public interface IMapper<Input, Output>
- {
- Output map_from(Input item);
- }
-}
\ No newline at end of file
product/Gorilla.Commons.Utility/Core/INotification.cs
@@ -1,7 +0,0 @@
-namespace Gorilla.Commons.Utility.Core
-{
- public interface INotification
- {
- void notify(params NotificationMessage[] messages);
- }
-}
\ No newline at end of file
product/Gorilla.Commons.Utility/Core/IParameterizedCommand.cs
@@ -1,7 +0,0 @@
-namespace Gorilla.Commons.Utility.Core
-{
- public interface IParameterizedCommand<T>
- {
- void run(T item);
- }
-}
\ No newline at end of file
product/Gorilla.Commons.Utility/Core/IParser.cs
@@ -1,7 +0,0 @@
-namespace Gorilla.Commons.Utility.Core
-{
- public interface IParser<T>
- {
- T parse();
- }
-}
\ No newline at end of file
product/Gorilla.Commons.Utility/Core/IQuery.cs
@@ -1,12 +0,0 @@
-namespace Gorilla.Commons.Utility.Core
-{
- public interface IQuery<TOutput>
- {
- TOutput fetch();
- }
-
- public interface IQuery<TInput, TOutput>
- {
- TOutput fetch(TInput item);
- }
-}
\ No newline at end of file
product/Gorilla.Commons.Utility/Core/IRegistry.cs
@@ -1,9 +0,0 @@
-using System.Collections.Generic;
-
-namespace Gorilla.Commons.Utility.Core
-{
- public interface IRegistry<T>
- {
- IEnumerable<T> all();
- }
-}
\ No newline at end of file
product/Gorilla.Commons.Utility/Core/ISpecification.cs
@@ -1,7 +0,0 @@
-namespace Gorilla.Commons.Utility.Core
-{
- public interface ISpecification<T>
- {
- bool is_satisfied_by(T item);
- }
-}
\ No newline at end of file
product/Gorilla.Commons.Utility/Core/IState.cs
@@ -1,6 +0,0 @@
-namespace Gorilla.Commons.Utility.Core
-{
- public interface IState
- {
- }
-}
\ No newline at end of file
product/Gorilla.Commons.Utility/Core/IStateContext.cs
@@ -1,7 +0,0 @@
-namespace Gorilla.Commons.Utility.Core
-{
- public interface IStateContext<T> where T : IState
- {
- void change_state_to(T new_state);
- }
-}
\ No newline at end of file
product/Gorilla.Commons.Utility/Core/IValueReturningVisitor.cs
@@ -1,8 +0,0 @@
-namespace Gorilla.Commons.Utility.Core
-{
- public interface IValueReturningVisitor<Value, T> : IVisitor<T>
- {
- Value value { get; }
- void reset();
- }
-}
\ No newline at end of file
product/Gorilla.Commons.Utility/Core/IVisitable.cs
@@ -1,7 +0,0 @@
-namespace Gorilla.Commons.Utility.Core
-{
- public interface IVisitable<T>
- {
- void accept(IVisitor<T> visitor);
- }
-}
\ No newline at end of file
product/Gorilla.Commons.Utility/Core/IVisitor.cs
@@ -1,7 +0,0 @@
-namespace Gorilla.Commons.Utility.Core
-{
- public interface IVisitor<T>
- {
- void visit(T item_to_visit);
- }
-}
\ No newline at end of file
product/Gorilla.Commons.Utility/Core/Mapper.cs
@@ -1,19 +0,0 @@
-using System;
-
-namespace Gorilla.Commons.Utility.Core
-{
- public class Mapper<Input, Output> : IMapper<Input, Output>
- {
- private readonly Converter<Input, Output> converter;
-
- public Mapper(Converter<Input, Output> converter)
- {
- this.converter = converter;
- }
-
- public Output map_from(Input item)
- {
- return converter(item);
- }
- }
-}
\ No newline at end of file
product/Gorilla.Commons.Utility/Core/NotSpecification.cs
@@ -1,17 +0,0 @@
-namespace Gorilla.Commons.Utility.Core
-{
- public class NotSpecification<T> : ISpecification<T>
- {
- readonly ISpecification<T> item_to_match;
-
- public NotSpecification(ISpecification<T> item_to_match)
- {
- this.item_to_match = item_to_match;
- }
-
- public bool is_satisfied_by(T item)
- {
- return !item_to_match.is_satisfied_by(item);
- }
- }
-}
\ No newline at end of file
product/Gorilla.Commons.Utility/Core/NotSpecificationSpecs.cs
@@ -1,46 +0,0 @@
-using developwithpassion.bdd.contexts;
-using Gorilla.Commons.Testing;
-
-namespace Gorilla.Commons.Utility.Core
-{
- public class NotSpecificationSpecs
- {
- }
-
- [Concern(typeof (NotSpecification<>))]
- public class when_checking_if_a_condition_is_not_met : concerns_for<ISpecification<int>, NotSpecification<int>>
- {
- static protected ISpecification<int> criteria;
-
- context c = () => { criteria = the_dependency<ISpecification<int>>(); };
-
- public override ISpecification<int> create_sut()
- {
- return new NotSpecification<int>(criteria);
- }
- }
-
- [Concern(typeof (NotSpecification<>))]
- public class when_a_condition_is_not_met : when_checking_if_a_condition_is_not_met
- {
- context c = () => when_the(criteria).is_told_to(x => x.is_satisfied_by(1)).it_will_return(false);
-
- because b = () => { result = sut.is_satisfied_by(1); };
-
- it should_return_true = () => result.should_be_true();
-
- static bool result;
- }
-
- [Concern(typeof (NotSpecification<>))]
- public class when_a_condition_is_met : when_checking_if_a_condition_is_not_met
- {
- context c = () => when_the(criteria).is_told_to(x => x.is_satisfied_by(1)).it_will_return(true);
-
- because b = () => { result = sut.is_satisfied_by(1); };
-
- it should_return_false = () => result.should_be_false();
-
- static bool result;
- }
-}
\ No newline at end of file
product/Gorilla.Commons.Utility/Core/OrSpecification.cs
@@ -1,19 +0,0 @@
-namespace Gorilla.Commons.Utility.Core
-{
- public class OrSpecification<T> : ISpecification<T>
- {
- readonly ISpecification<T> left;
- readonly ISpecification<T> right;
-
- public OrSpecification(ISpecification<T> left, ISpecification<T> right)
- {
- this.left = left;
- this.right = right;
- }
-
- public bool is_satisfied_by(T item)
- {
- return left.is_satisfied_by(item) || right.is_satisfied_by(item);
- }
- }
-}
\ No newline at end of file
product/Gorilla.Commons.Utility/Core/OrSpecificationSpecs.cs
@@ -1,55 +0,0 @@
-using developwithpassion.bdd.contexts;
-using Gorilla.Commons.Testing;
-
-namespace Gorilla.Commons.Utility.Core
-{
- [Concern(typeof (OrSpecification<>))]
- public abstract class when_checking_if_one_of_two_conditions_are_met : concerns_for<ISpecification<int>, OrSpecification<int>>
- {
- public override ISpecification<int> create_sut()
- {
- return new OrSpecification<int>(left, right);
- }
-
- context c = () =>
- {
- left = an<ISpecification<int>>();
- right = an<ISpecification<int>>();
- };
-
- protected static ISpecification<int> left;
- protected static ISpecification<int> right;
- }
-
- [Concern(typeof (OrSpecification<>))]
- public class when_one_of_the_conditions_is_met : when_checking_if_one_of_two_conditions_are_met
- {
- it should_return_true = () => result.should_be_true();
-
- context c = () => when_the(left).is_told_to(x => x.is_satisfied_by(1)).it_will_return(true);
- because b = () => { result = sut.is_satisfied_by(1); };
-
- static bool result;
- }
-
- [Concern(typeof (OrSpecification<>))]
- public class when_the_second_condition_is_met : when_checking_if_one_of_two_conditions_are_met
- {
- it should_return_true = () => result.should_be_true();
-
- context c = () => when_the(right).is_told_to(x => x.is_satisfied_by(1)).it_will_return(true);
- because b = () => { result = sut.is_satisfied_by(1); };
-
- static bool result;
- }
-
- [Concern(typeof (OrSpecification<>))]
- public class when_neither_conditions_are_met : when_checking_if_one_of_two_conditions_are_met
- {
- it should_return_false = () => result.should_be_false();
-
- because b = () => { result = sut.is_satisfied_by(1); };
-
- static bool result;
- }
-}
\ No newline at end of file
product/Gorilla.Commons.Utility/Core/PredicateSpecificationSpecs.cs
@@ -1,17 +0,0 @@
-using developwithpassion.bdd.contexts;
-using Gorilla.Commons.Testing;
-
-namespace Gorilla.Commons.Utility.Core
-{
- [Concern(typeof (PredicateSpecification<>))]
- public class when_checking_if_a_criteria_is_met_and_it_is : concerns
- {
- it should_return_true = () => new PredicateSpecification<int>(x => true).is_satisfied_by(1).should_be_true();
- }
-
- [Concern(typeof (PredicateSpecification<>))]
- public class when_checking_if_a_criteria_is_met_and_it_is_not : concerns
- {
- it should_return_true = () => new PredicateSpecification<int>(x => false).is_satisfied_by(1).should_be_false();
- }
-}
\ No newline at end of file
product/Gorilla.Commons.Utility/Extensions/CommandExtensions.cs
@@ -1,23 +0,0 @@
-using System;
-using Gorilla.Commons.Utility.Core;
-
-namespace Gorilla.Commons.Utility.Extensions
-{
- static public class CommandExtensions
- {
- static public ICommand then<Command>(this ICommand left) where Command : ICommand, new()
- {
- return then(left, new Command());
- }
-
- static public ICommand then(this ICommand left, ICommand right)
- {
- return new ChainedCommand(left, right);
- }
-
- static public ICommand then(this ICommand left, Action right)
- {
- return new ChainedCommand(left, new ActionCommand(right));
- }
- }
-}
\ No newline at end of file
product/Gorilla.Commons.Utility/Extensions/ConfigurationExtensions.cs
@@ -1,18 +0,0 @@
-using Gorilla.Commons.Utility.Core;
-
-namespace Gorilla.Commons.Utility.Extensions
-{
- static public class ConfigurationExtensions
- {
- static public IConfiguration<T> then<T>(this IConfiguration<T> first, IConfiguration<T> second)
- {
- return new ChainedConfiguration<T>(first, second);
- }
-
- static public T and_configure_with<T>(this T item, IConfiguration<T> configuration)
- {
- configuration.configure(item);
- return item;
- }
- }
-}
\ No newline at end of file
product/Gorilla.Commons.Utility/Extensions/ConfigurationExtensionsSpecs.cs
@@ -1,28 +0,0 @@
-using System.Data;
-using developwithpassion.bdd.contexts;
-using Gorilla.Commons.Testing;
-using Gorilla.Commons.Utility.Core;
-
-namespace Gorilla.Commons.Utility.Extensions
-{
- public class ConfigurationExtensionsSpecs
- {
- }
-
- public class when_configuring_an_item : concerns
- {
- it should_return_the_item_that_was_configured_when_completed = () => result.should_be_equal_to(item);
-
- context c = () =>
- {
- configuration = an<IConfiguration<IDbCommand>>();
- item = an<IDbCommand>();
- };
-
- because b = () => { result = item.and_configure_with(configuration); };
-
- static IConfiguration<IDbCommand> configuration;
- static IDbCommand item;
- static IDbCommand result;
- }
-}
\ No newline at end of file
product/Gorilla.Commons.Utility/Extensions/EnumerableExtensionsSpecs.cs
@@ -1,30 +0,0 @@
-using System.Collections.Generic;
-using developwithpassion.bdd.contexts;
-using Gorilla.Commons.Testing;
-
-namespace Gorilla.Commons.Utility.Extensions
-{
- public class EnumerableExtensionsSpecs
- {
- }
-
- [Concern(typeof (EnumerableExtensions))]
- public class when_joining_one_collection_with_another : concerns
- {
- it should_return_the_items_from_both = () =>
- {
- results.should_contain(1);
- results.should_contain(2);
- };
-
- because b = () => { results = new List<int> {1}.join_with(new List<int> {2}); };
-
- static IEnumerable<int> results;
- }
-
- [Concern(typeof (EnumerableExtensions))]
- public class when_attemping_to_join_a_list_with_a_null_value : concerns
- {
- it should_return_the_original_list = () => new List<int> {1}.join_with(null).should_contain(1);
- }
-}
\ No newline at end of file
product/Gorilla.Commons.Utility/Extensions/FuncExtensions.cs
@@ -1,26 +0,0 @@
-using System;
-
-namespace Gorilla.Commons.Utility.Extensions
-{
- public static class FuncExtensions
- {
- public static Func<T> memorize<T>(this Func<T> item) where T : class
- {
- T the_implementation = null;
- return () =>
- {
- if (null == the_implementation)
- {
- lock (typeof (FuncExtensions))
- {
- if (null == the_implementation)
- {
- the_implementation = item();
- }
- }
- }
- return the_implementation;
- };
- }
- }
-}
\ No newline at end of file
product/Gorilla.Commons.Utility/Extensions/ListExtensionsSpecs.cs
@@ -1,65 +0,0 @@
-using System.Collections.Generic;
-using developwithpassion.bdd.contexts;
-using Gorilla.Commons.Testing;
-
-namespace Gorilla.Commons.Utility.Extensions
-{
- [Concern(typeof (ListExtensions))]
- public class when_adding_an_item_to_a_list : concerns
- {
- because b = () =>
- {
- list = new List<string>();
- list.add("mo");
- };
-
- it should_add_the_item_to_the_list = () => list.should_contain("mo");
-
- static List<string> list;
- }
-
- [Concern(typeof (ListExtensions))]
- public abstract class when_asked_to_only_add_an_item_to_a_list_if_a_condition_is_not_met : concerns
- {
- context c = () => { list = new List<string>(); };
-
- static protected List<string> list;
- }
-
- [Concern(typeof (ListExtensions))]
- public class when_the_condition_is_not_met : when_asked_to_only_add_an_item_to_a_list_if_a_condition_is_not_met
- {
- because b = () => list.add("mo").unless(x => false);
-
- it should_add_the_item_to_the_list = () => list.should_contain("mo");
- }
-
- [Concern(typeof (ListExtensions))]
- public class when_the_condition_is_met : when_asked_to_only_add_an_item_to_a_list_if_a_condition_is_not_met
- {
- because b = () => list.add("mo").unless(x => true);
-
- it should_not_add_the_item_to_the_list = () => list.should_not_contain("mo");
- }
-
- [Concern(typeof (ListExtensions))]
- public class when_some_of_the_items_meet_the_conditions_and_some_do_not :
- when_asked_to_only_add_an_item_to_a_list_if_a_condition_is_not_met
- {
- because b = () => list
- .add_range(new List<string> {"mo", "khan"})
- .unless(x => x.Equals("mo"));
-
- it should_add_the_items_that_do_not_meet_the_condition = () =>
- {
- list.Count.should_be_equal_to(1);
- list.should_contain("khan");
- };
-
- it should_not_add_the_items_that_do_meet_the_condition = () => list.should_not_contain("mo");
- }
-
- public class ListExtensionsSpecs
- {
- }
-}
\ No newline at end of file
product/Gorilla.Commons.Utility/Extensions/MappingExtensionsSpecs.cs
@@ -1,30 +0,0 @@
-using developwithpassion.bdd.contexts;
-using Gorilla.Commons.Testing;
-using Gorilla.Commons.Utility.Core;
-
-namespace Gorilla.Commons.Utility.Extensions
-{
- [Concern(typeof (MappingExtensions))]
- public class when_transforming_type_A_to_type_B_then_C : concerns
- {
- it should_return_the_correct_result = () => result.should_be_equal_to(1);
-
- context c = () =>
- {
- first_mapper = an<IMapper<object, string>>();
- second_mapper = an<IMapper<string, int>>();
- a = 1;
-
- when_the(first_mapper).is_told_to(x => x.map_from(a)).it_will_return("1");
- when_the(second_mapper).is_told_to(x => x.map_from("1")).it_will_return(1);
- };
-
- because b = () => { result = first_mapper.then(second_mapper).map_from(a); };
-
-
- static int result;
- static IMapper<object, string> first_mapper;
- static IMapper<string, int> second_mapper;
- static object a;
- }
-}
\ No newline at end of file
product/Gorilla.Commons.Utility/Extensions/SpecificationExtensionsSpecs.cs
@@ -1,67 +0,0 @@
-using developwithpassion.bdd.contexts;
-using Gorilla.Commons.Testing;
-using Gorilla.Commons.Utility.Core;
-
-namespace Gorilla.Commons.Utility.Extensions
-{
- public abstract class when_evaluating_two_conditions : concerns
- {
- context c = () =>
- {
- left = an<ISpecification<int>>();
- right = an<ISpecification<int>>();
- };
-
- static protected ISpecification<int> left;
- static protected ISpecification<int> right;
- }
-
- [Concern(typeof (SpecificationExtensions))]
- public class when_checking_if_two_conditions_are_met_and_they_are : when_evaluating_two_conditions
- {
- it should_return_true = () => result.should_be_true();
-
- context c = () =>
- {
- when_the(right).is_told_to(x => x.is_satisfied_by(1)).it_will_return(true);
- when_the(left).is_told_to(x => x.is_satisfied_by(1)).it_will_return(true);
- };
-
- because b = () => { result = left.or(right).is_satisfied_by(1); };
-
- static bool result;
- }
-
- [Concern(typeof (SpecificationExtensions))]
- public class when_checking_if_one_of_two_conditions_are_met_and_the_left_one_is_not : when_evaluating_two_conditions
- {
- it should_return_true = () => result.should_be_true();
-
- context c = () =>
- {
- when_the(right).is_told_to(x => x.is_satisfied_by(1)).it_will_return(true);
- when_the(left).is_told_to(x => x.is_satisfied_by(1)).it_will_return(false);
- };
-
- because b = () => { result = left.or(right).is_satisfied_by(1); };
-
- static bool result;
- }
-
- [Concern(typeof (SpecificationExtensions))]
- public class when_checking_if_one_of_two_conditions_are_met_and_the_right_one_is_not :
- when_evaluating_two_conditions
- {
- it should_return_true = () => result.should_be_true();
-
- context c = () =>
- {
- when_the(right).is_told_to(x => x.is_satisfied_by(1)).it_will_return(false);
- when_the(left).is_told_to(x => x.is_satisfied_by(1)).it_will_return(true);
- };
-
- because b = () => { result = left.or(right).is_satisfied_by(1); };
-
- static bool result;
- }
-}
\ No newline at end of file
product/Gorilla.Commons.Utility/Extensions/TypeExtensionsSpecs.cs
@@ -1,44 +0,0 @@
-using developwithpassion.bdd.contexts;
-using Gorilla.Commons.Testing;
-using Gorilla.Commons.Utility.Core;
-
-namespace Gorilla.Commons.Utility.Extensions
-{
- [Concern(typeof (TypeExtensions))]
- public class when_getting_the_last_interface_for_a_type : concerns
- {
- it should_return_the_correct_one =
- () => typeof (TestType).last_interface().should_be_equal_to(typeof (ITestType));
- }
-
- [Concern(typeof (TypeExtensions))]
- public class when_getting_the_first_interface_for_a_type : concerns
- {
- it should_return_the_correct_one = () => typeof (TestType).first_interface().should_be_equal_to(typeof (IBase));
- }
-
- [Concern(typeof (TypeExtensions))]
- public class when_checking_if_a_type_represents_a_generic_type_definition : concerns
- {
- it should_tell_the_truth = () => {
- typeof (IRegistry<>).is_a_generic_type().should_be_true();
- typeof (IRegistry<int>).is_a_generic_type().should_be_false();
- };
- }
-
- public interface IBase
- {
- }
-
- public class BaseType : IBase
- {
- }
-
- public interface ITestType
- {
- }
-
- public class TestType : BaseType, ITestType
- {
- }
-}
\ No newline at end of file
product/Gorilla.Commons.Utility/Extensions/VisitorExtensions.cs
@@ -1,20 +0,0 @@
-using System.Collections.Generic;
-using Gorilla.Commons.Utility.Core;
-
-namespace Gorilla.Commons.Utility.Extensions
-{
- static public class VisitorExtensions
- {
- static public Result return_value_from_visiting_all_items_with<Result, T>(this IEnumerable<T> items, IValueReturningVisitor<Result, T> visitor)
- {
- visitor.reset();
- items.visit_all_items_with(visitor);
- return visitor.value;
- }
-
- static public void visit_all_items_with<T>(this IEnumerable<T> items, IVisitor<T> visitor)
- {
- items.each(visitor.visit);
- }
- }
-}
\ No newline at end of file
product/Gorilla.Commons.Utility/AndSpecification.cs
@@ -0,0 +1,19 @@
+namespace gorilla.commons.utility
+{
+ public class AndSpecification<T> : Specification<T>
+ {
+ readonly Specification<T> left;
+ readonly Specification<T> right;
+
+ public AndSpecification(Specification<T> left, Specification<T> right)
+ {
+ this.left = left;
+ this.right = right;
+ }
+
+ public bool is_satisfied_by(T item)
+ {
+ return left.is_satisfied_by(item) && right.is_satisfied_by(item);
+ }
+ }
+}
\ No newline at end of file
product/Gorilla.Commons.Utility/AnonymousCommand.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Linq.Expressions;
+
+namespace gorilla.commons.utility
+{
+ public class AnonymousCommand : Command
+ {
+ readonly Action action;
+
+ public AnonymousCommand(Expression<Action> action) : this(action.Compile()) {}
+
+ public AnonymousCommand(Action action)
+ {
+ this.action = action;
+ }
+
+ public void run()
+ {
+ action();
+ }
+ }
+}
\ No newline at end of file
product/Gorilla.Commons.Utility/Core/AnonymousDisposable.cs → product/Gorilla.Commons.Utility/AnonymousDisposable.cs
@@ -1,6 +1,6 @@
using System;
-namespace Gorilla.Commons.Utility.Core
+namespace gorilla.commons.utility
{
public class AnonymousDisposable : IDisposable
{
product/Gorilla.Commons.Utility/AnonymousMapper.cs
@@ -0,0 +1,19 @@
+using System;
+
+namespace gorilla.commons.utility
+{
+ public class AnonymousMapper<Input, Output> : Mapper<Input, Output>
+ {
+ readonly Converter<Input, Output> converter;
+
+ public AnonymousMapper(Converter<Input, Output> converter)
+ {
+ this.converter = converter;
+ }
+
+ public Output map_from(Input item)
+ {
+ return converter(item);
+ }
+ }
+}
\ No newline at end of file
product/Gorilla.Commons.Utility/Builder.cs
@@ -0,0 +1,7 @@
+namespace gorilla.commons.utility
+{
+ public interface Builder<T>
+ {
+ T build();
+ }
+}
\ No newline at end of file
product/Gorilla.Commons.Utility/Callback.cs
@@ -0,0 +1,10 @@
+namespace gorilla.commons.utility
+{
+ public interface Callback : Command
+ {
+ }
+
+ public interface Callback<T> : ParameterizedCommand<T>
+ {
+ }
+}
\ No newline at end of file
product/Gorilla.Commons.Utility/CallbackCommand.cs
@@ -0,0 +1,6 @@
+namespace gorilla.commons.utility
+{
+ public interface CallbackCommand<T> : ParameterizedCommand<Callback<T>>
+ {
+ }
+}
\ No newline at end of file
product/Gorilla.Commons.Utility/ChainedCommand.cs
@@ -0,0 +1,20 @@
+namespace gorilla.commons.utility
+{
+ public class ChainedCommand : Command
+ {
+ readonly Command left;
+ readonly Command right;
+
+ public ChainedCommand(Command left, Command right)
+ {
+ this.left = left;
+ this.right = right;
+ }
+
+ public void run()
+ {
+ left.run();
+ right.run();
+ }
+ }
+}
\ No newline at end of file
product/Gorilla.Commons.Utility/ChainedConfiguration.cs
@@ -0,0 +1,20 @@
+namespace gorilla.commons.utility
+{
+ public class ChainedConfiguration<T> : Configuration<T>
+ {
+ readonly Configuration<T> first;
+ readonly Configuration<T> second;
+
+ public ChainedConfiguration(Configuration<T> first, Configuration<T> second)
+ {
+ this.first = first;
+ this.second = second;
+ }
+
+ public void configure(T item)
+ {
+ first.configure(item);
+ second.configure(item);
+ }
+ }
+}
\ No newline at end of file
product/Gorilla.Commons.Utility/ChainedMapper.cs
@@ -0,0 +1,19 @@
+namespace gorilla.commons.utility
+{
+ public class ChainedMapper<Left, Middle, Right> : Mapper<Left, Right>
+ {
+ readonly Mapper<Left, Middle> left;
+ readonly Mapper<Middle, Right> right;
+
+ public ChainedMapper(Mapper<Left, Middle> left, Mapper<Middle, Right> right)
+ {
+ this.left = left;
+ this.right = right;
+ }
+
+ public Right map_from(Left item)
+ {
+ return right.map_from(left.map_from(item));
+ }
+ }
+}
\ No newline at end of file
product/Gorilla.Commons.Utility/Command.cs
@@ -0,0 +1,7 @@
+namespace gorilla.commons.utility
+{
+ public interface Command
+ {
+ void run();
+ }
+}
\ No newline at end of file
product/Gorilla.Commons.Utility/CommandExtensions.cs
@@ -0,0 +1,22 @@
+using System;
+
+namespace gorilla.commons.utility
+{
+ static public class CommandExtensions
+ {
+ static public utility.Command then<Command>(this utility.Command left) where Command : utility.Command, new()
+ {
+ return then(left, new Command());
+ }
+
+ static public Command then(this Command left, Command right)
+ {
+ return new ChainedCommand(left, right);
+ }
+
+ static public Command then(this Command left, Action right)
+ {
+ return new ChainedCommand(left, new AnonymousCommand(right));
+ }
+ }
+}
\ No newline at end of file
product/Gorilla.Commons.Utility/ComponentFactory.cs
@@ -0,0 +1,4 @@
+namespace gorilla.commons.utility
+{
+ public interface ComponentFactory<T> : Factory<T> where T : new() {}
+}
\ No newline at end of file
product/Gorilla.Commons.Utility/Configuration.cs
@@ -0,0 +1,7 @@
+namespace gorilla.commons.utility
+{
+ public interface Configuration<T>
+ {
+ void configure(T item);
+ }
+}
\ No newline at end of file
product/Gorilla.Commons.Utility/ConfigurationExtensions.cs
@@ -0,0 +1,16 @@
+namespace gorilla.commons.utility
+{
+ static public class ConfigurationExtensions
+ {
+ static public Configuration<T> then<T>(this Configuration<T> first, Configuration<T> second)
+ {
+ return new ChainedConfiguration<T>(first, second);
+ }
+
+ static public T and_configure_with<T>(this T item, Configuration<T> configuration)
+ {
+ configuration.configure(item);
+ return item;
+ }
+ }
+}
\ No newline at end of file
product/Gorilla.Commons.Utility/ConfigurationExtensionsSpecs.cs
@@ -0,0 +1,29 @@
+using System.Data;
+using developwithpassion.bdd.contexts;
+using Gorilla.Commons.Testing;
+
+namespace gorilla.commons.utility
+{
+ public class ConfigurationExtensionsSpecs
+ {
+ public class when_configuring_an_item : concerns
+ {
+ it should_return_the_item_that_was_configured_when_completed = () => result.should_be_equal_to(item);
+
+ context c = () =>
+ {
+ configuration = an<Configuration<IDbCommand>>();
+ item = an<IDbCommand>();
+ };
+
+ because b = () =>
+ {
+ result = item.and_configure_with(configuration);
+ };
+
+ static Configuration<IDbCommand> configuration;
+ static IDbCommand item;
+ static IDbCommand result;
+ }
+ }
+}
\ No newline at end of file
product/Gorilla.Commons.Utility/Extensions/ConversionExtensions.cs → product/Gorilla.Commons.Utility/ConversionExtensions.cs
@@ -1,7 +1,7 @@
using System;
using System.Collections;
-namespace Gorilla.Commons.Utility.Extensions
+namespace gorilla.commons.utility
{
public static class ConversionExtensions
{
product/Gorilla.Commons.Utility/Date.cs
@@ -1,6 +1,6 @@
using System;
using System.Globalization;
-using Gorilla.Commons.Utility.Extensions;
+using gorilla.commons.utility;
namespace Gorilla.Commons.Utility
{
product/Gorilla.Commons.Utility/DefaultConstructorFactory.cs
@@ -0,0 +1,10 @@
+namespace gorilla.commons.utility
+{
+ public class DefaultConstructorFactory<T> : ComponentFactory<T> where T : new()
+ {
+ public T create()
+ {
+ return new T();
+ }
+ }
+}
\ No newline at end of file
product/Gorilla.Commons.Utility/DisposableCommand.cs
@@ -0,0 +1,7 @@
+using System;
+using gorilla.commons.utility;
+
+namespace gorilla.commons.Utility
+{
+ public interface DisposableCommand : Command, IDisposable {}
+}
\ No newline at end of file
product/Gorilla.Commons.Utility/EmptyCallback.cs
@@ -0,0 +1,9 @@
+namespace gorilla.commons.utility
+{
+ public class EmptyCallback<T> : Callback<T>, Callback
+ {
+ public void run(T item) {}
+
+ public void run() {}
+ }
+}
\ No newline at end of file
product/Gorilla.Commons.Utility/EmptyCommand.cs
@@ -0,0 +1,9 @@
+namespace gorilla.commons.utility
+{
+ public class EmptyCommand : Command
+ {
+ public void run()
+ {
+ }
+ }
+}
\ No newline at end of file
product/Gorilla.Commons.Utility/Extensions/EnumerableExtensions.cs → product/Gorilla.Commons.Utility/EnumerableExtensions.cs
@@ -2,7 +2,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
-namespace Gorilla.Commons.Utility.Extensions
+namespace gorilla.commons.utility
{
static public class EnumerableExtensions
{
product/Gorilla.Commons.Utility/EnumerableExtensionsSpecs.cs
@@ -0,0 +1,32 @@
+using System.Collections.Generic;
+using developwithpassion.bdd.contexts;
+using Gorilla.Commons.Testing;
+
+namespace gorilla.commons.utility
+{
+ public class EnumerableExtensionsSpecs
+ {
+ [Concern(typeof (EnumerableExtensions))]
+ public class when_joining_one_collection_with_another : concerns
+ {
+ it should_return_the_items_from_both = () =>
+ {
+ results.should_contain(1);
+ results.should_contain(2);
+ };
+
+ because b = () =>
+ {
+ results = new List<int> {1}.join_with(new List<int> {2});
+ };
+
+ static IEnumerable<int> results;
+ }
+
+ [Concern(typeof (EnumerableExtensions))]
+ public class when_attemping_to_join_a_list_with_a_null_value : concerns
+ {
+ it should_return_the_original_list = () => new List<int> {1}.join_with(null).should_contain(1);
+ }
+ }
+}
\ No newline at end of file
product/Gorilla.Commons.Utility/Factory.cs
@@ -0,0 +1,7 @@
+namespace gorilla.commons.utility
+{
+ public interface Factory<T>
+ {
+ T create();
+ }
+}
\ No newline at end of file
product/Gorilla.Commons.Utility/FactoryDelegate.cs
@@ -0,0 +1,6 @@
+namespace gorilla.commons.utility
+{
+ public delegate Out FactoryDelegate<In, Out>(In input);
+
+ public delegate Out FactoryDelegate<Out>();
+}
\ No newline at end of file
product/Gorilla.Commons.Utility/Core/FilteredVisitor.cs → product/Gorilla.Commons.Utility/FilteredVisitor.cs
@@ -1,11 +1,11 @@
-namespace Gorilla.Commons.Utility.Core
+namespace gorilla.commons.utility
{
- public class FilteredVisitor<T> : IVisitor<T>
+ public class FilteredVisitor<T> : Visitor<T>
{
- readonly ISpecification<T> condition;
- readonly IVisitor<T> visitor;
+ readonly Specification<T> condition;
+ readonly Visitor<T> visitor;
- public FilteredVisitor(ISpecification<T> condition, IVisitor<T> visitor)
+ public FilteredVisitor(Specification<T> condition, Visitor<T> visitor)
{
this.condition = condition;
this.visitor = visitor;
product/Gorilla.Commons.Utility/FuncExtensions.cs
@@ -0,0 +1,28 @@
+using System;
+
+namespace gorilla.commons.utility
+{
+ static public class FuncExtensions
+ {
+ static public readonly object mutex = new object();
+
+ static public Func<T> memorize<T>(this Func<T> item) where T : class
+ {
+ T the_implementation = null;
+ return () =>
+ {
+ if (null == the_implementation)
+ {
+ lock (mutex)
+ {
+ if (null == the_implementation)
+ {
+ the_implementation = item();
+ }
+ }
+ }
+ return the_implementation;
+ };
+ }
+ }
+}
\ No newline at end of file
product/Gorilla.Commons.Utility/Core/FuncSpecification.cs → product/Gorilla.Commons.Utility/FuncSpecification.cs
@@ -1,8 +1,8 @@
using System;
-namespace Gorilla.Commons.Utility.Core
+namespace gorilla.commons.utility
{
- public class FuncSpecification<T> : ISpecification<T>
+ public class FuncSpecification<T> : Specification<T>
{
Func<T, bool> condition;
product/Gorilla.Commons.Utility/Core/Id.cs → product/Gorilla.Commons.Utility/Id.cs
@@ -1,6 +1,6 @@
using System;
-namespace Gorilla.Commons.Utility.Core
+namespace gorilla.commons.utility
{
[Serializable]
public class Id<T>
product/Gorilla.Commons.Utility/Identifiable.cs
@@ -0,0 +1,7 @@
+namespace gorilla.commons.utility
+{
+ public interface Identifiable<T>
+ {
+ Id<T> id { get; }
+ }
+}
\ No newline at end of file
product/Gorilla.Commons.Utility/Import.cs
@@ -0,0 +1,7 @@
+namespace gorilla.commons.utility
+{
+ public interface Import<T>
+ {
+ void import(T item);
+ }
+}
\ No newline at end of file
product/Gorilla.Commons.Utility/Extensions/ListExtensions.cs → product/Gorilla.Commons.Utility/ListExtensions.cs
@@ -2,7 +2,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
-namespace Gorilla.Commons.Utility.Extensions
+namespace gorilla.commons.utility
{
static public class ListExtensions
{
product/Gorilla.Commons.Utility/ListExtensionsSpecs.cs
@@ -0,0 +1,67 @@
+using System.Collections.Generic;
+using developwithpassion.bdd.contexts;
+using Gorilla.Commons.Testing;
+
+namespace gorilla.commons.utility
+{
+ public class ListExtensionsSpecs
+ {
+ [Concern(typeof (ListExtensions))]
+ public class when_adding_an_item_to_a_list : concerns
+ {
+ because b = () =>
+ {
+ list = new List<string>();
+ list.add("mo");
+ };
+
+ it should_add_the_item_to_the_list = () => list.should_contain("mo");
+
+ static List<string> list;
+ }
+
+ [Concern(typeof (ListExtensions))]
+ public abstract class when_asked_to_only_add_an_item_to_a_list_if_a_condition_is_not_met : concerns
+ {
+ context c = () =>
+ {
+ list = new List<string>();
+ };
+
+ static protected List<string> list;
+ }
+
+ [Concern(typeof (ListExtensions))]
+ public class when_the_condition_is_not_met : when_asked_to_only_add_an_item_to_a_list_if_a_condition_is_not_met
+ {
+ because b = () => list.add("mo").unless(x => false);
+
+ it should_add_the_item_to_the_list = () => list.should_contain("mo");
+ }
+
+ [Concern(typeof (ListExtensions))]
+ public class when_the_condition_is_met : when_asked_to_only_add_an_item_to_a_list_if_a_condition_is_not_met
+ {
+ because b = () => list.add("mo").unless(x => true);
+
+ it should_not_add_the_item_to_the_list = () => list.should_not_contain("mo");
+ }
+
+ [Concern(typeof (ListExtensions))]
+ public class when_some_of_the_items_meet_the_conditions_and_some_do_not :
+ when_asked_to_only_add_an_item_to_a_list_if_a_condition_is_not_met
+ {
+ because b = () => list
+ .add_range(new List<string> {"mo", "khan"})
+ .unless(x => x.Equals("mo"));
+
+ it should_add_the_items_that_do_not_meet_the_condition = () =>
+ {
+ list.Count.should_be_equal_to(1);
+ list.should_contain("khan");
+ };
+
+ it should_not_add_the_items_that_do_meet_the_condition = () => list.should_not_contain("mo");
+ }
+ }
+}
\ No newline at end of file
product/Gorilla.Commons.Utility/Mapper.cs
@@ -0,0 +1,7 @@
+namespace gorilla.commons.utility
+{
+ public interface Mapper<Input, Output>
+ {
+ Output map_from(Input item);
+ }
+}
\ No newline at end of file
product/Gorilla.Commons.Utility/Extensions/MappingExtensions.cs → product/Gorilla.Commons.Utility/MappingExtensions.cs
@@ -1,9 +1,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
-using Gorilla.Commons.Utility.Core;
-namespace Gorilla.Commons.Utility.Extensions
+namespace gorilla.commons.utility
{
public static class MappingExtensions
{
@@ -12,7 +11,7 @@ namespace Gorilla.Commons.Utility.Extensions
return conversion(item);
}
- public static Output map_using<Input, Output>(this Input item, IMapper<Input, Output> mapper)
+ public static Output map_using<Input, Output>(this Input item, Mapper<Input, Output> mapper)
{
return map_using(item, x => mapper.map_from(x));
}
@@ -24,13 +23,13 @@ namespace Gorilla.Commons.Utility.Extensions
}
public static IEnumerable<Output> map_all_using<Input, Output>(this IEnumerable<Input> items,
- IMapper<Input, Output> mapper)
+ Mapper<Input, Output> mapper)
{
return map_all_using(items, x => mapper.map_from(x));
}
- public static IMapper<Left, Right> then<Left, Middle, Right>(this IMapper<Left, Middle> left,
- IMapper<Middle, Right> right)
+ public static Mapper<Left, Right> then<Left, Middle, Right>(this Mapper<Left, Middle> left,
+ Mapper<Middle, Right> right)
{
return new ChainedMapper<Left, Middle, Right>(left, right);
}
product/Gorilla.Commons.Utility/MappingExtensionsSpecs.cs
@@ -0,0 +1,29 @@
+using developwithpassion.bdd.contexts;
+using Gorilla.Commons.Testing;
+
+namespace gorilla.commons.utility
+{
+ [Concern(typeof (MappingExtensions))]
+ public class when_transforming_type_A_to_type_B_then_C : concerns
+ {
+ it should_return_the_correct_result = () => result.should_be_equal_to(1);
+
+ context c = () =>
+ {
+ first_mapper = an<Mapper<object, string>>();
+ second_mapper = an<Mapper<string, int>>();
+ a = 1;
+
+ when_the(first_mapper).is_told_to(x => x.map_from(a)).it_will_return("1");
+ when_the(second_mapper).is_told_to(x => x.map_from("1")).it_will_return(1);
+ };
+
+ because b = () => { result = first_mapper.then(second_mapper).map_from(a); };
+
+
+ static int result;
+ static Mapper<object, string> first_mapper;
+ static Mapper<string, int> second_mapper;
+ static object a;
+ }
+}
\ No newline at end of file
product/Gorilla.Commons.Utility/Notification.cs
@@ -0,0 +1,7 @@
+namespace gorilla.commons.utility
+{
+ public interface Notification
+ {
+ void notify(params NotificationMessage[] messages);
+ }
+}
\ No newline at end of file
product/Gorilla.Commons.Utility/Core/NotificationMessage.cs → product/Gorilla.Commons.Utility/NotificationMessage.cs
@@ -1,8 +1,8 @@
-namespace Gorilla.Commons.Utility.Core
+namespace gorilla.commons.utility
{
public class NotificationMessage
{
- public string message { get; set; }
+ public virtual string message { get; set; }
static public implicit operator string(NotificationMessage message)
{
product/Gorilla.Commons.Utility/NotSpecification.cs
@@ -0,0 +1,17 @@
+namespace gorilla.commons.utility
+{
+ public class NotSpecification<T> : Specification<T>
+ {
+ readonly Specification<T> item_to_match;
+
+ public NotSpecification(Specification<T> item_to_match)
+ {
+ this.item_to_match = item_to_match;
+ }
+
+ public bool is_satisfied_by(T item)
+ {
+ return !item_to_match.is_satisfied_by(item);
+ }
+ }
+}
\ No newline at end of file
product/Gorilla.Commons.Utility/NotSpecificationSpecs.cs
@@ -0,0 +1,54 @@
+using developwithpassion.bdd.contexts;
+using Gorilla.Commons.Testing;
+
+namespace gorilla.commons.utility
+{
+ public class NotSpecificationSpecs
+ {
+ [Concern(typeof (NotSpecification<>))]
+ public class when_checking_if_a_condition_is_not_met : concerns_for<Specification<int>, NotSpecification<int>>
+ {
+ static protected Specification<int> criteria;
+
+ context c = () =>
+ {
+ criteria = the_dependency<Specification<int>>();
+ };
+
+ public override Specification<int> create_sut()
+ {
+ return new NotSpecification<int>(criteria);
+ }
+ }
+
+ [Concern(typeof (NotSpecification<>))]
+ public class when_a_condition_is_not_met : when_checking_if_a_condition_is_not_met
+ {
+ context c = () => when_the(criteria).is_told_to(x => x.is_satisfied_by(1)).it_will_return(false);
+
+ because b = () =>
+ {
+ result = sut.is_satisfied_by(1);
+ };
+
+ it should_return_true = () => result.should_be_true();
+
+ static bool result;
+ }
+
+ [Concern(typeof (NotSpecification<>))]
+ public class when_a_condition_is_met : when_checking_if_a_condition_is_not_met
+ {
+ context c = () => when_the(criteria).is_told_to(x => x.is_satisfied_by(1)).it_will_return(true);
+
+ because b = () =>
+ {
+ result = sut.is_satisfied_by(1);
+ };
+
+ it should_return_false = () => result.should_be_false();
+
+ static bool result;
+ }
+ }
+}
\ No newline at end of file
product/Gorilla.Commons.Utility/Extensions/NumericConversions.cs → product/Gorilla.Commons.Utility/NumericConversions.cs
@@ -1,6 +1,6 @@
using System;
-namespace Gorilla.Commons.Utility.Extensions
+namespace gorilla.commons.utility
{
public static class NumericConversions
{
product/Gorilla.Commons.Utility/Extensions/NumericConversionsSpecs.cs → product/Gorilla.Commons.Utility/NumericConversionsSpecs.cs
@@ -1,7 +1,7 @@
using developwithpassion.bdd.contexts;
using Gorilla.Commons.Testing;
-namespace Gorilla.Commons.Utility.Extensions
+namespace gorilla.commons.utility
{
[Concern(typeof (NumericConversions))]
public class when_converting_a_valid_string_to_a_long : concerns
product/Gorilla.Commons.Utility/OrSpecification.cs
@@ -0,0 +1,19 @@
+namespace gorilla.commons.utility
+{
+ public class OrSpecification<T> : Specification<T>
+ {
+ readonly Specification<T> left;
+ readonly Specification<T> right;
+
+ public OrSpecification(Specification<T> left, Specification<T> right)
+ {
+ this.left = left;
+ this.right = right;
+ }
+
+ public bool is_satisfied_by(T item)
+ {
+ return left.is_satisfied_by(item) || right.is_satisfied_by(item);
+ }
+ }
+}
\ No newline at end of file
product/Gorilla.Commons.Utility/OrSpecificationSpecs.cs
@@ -0,0 +1,69 @@
+using developwithpassion.bdd.contexts;
+using Gorilla.Commons.Testing;
+
+namespace gorilla.commons.utility
+{
+ public class OrSpecificationSpecs
+ {
+ [Concern(typeof (OrSpecification<>))]
+ public abstract class when_checking_if_one_of_two_conditions_are_met : concerns_for<Specification<int>, OrSpecification<int>>
+ {
+ public override Specification<int> create_sut()
+ {
+ return new OrSpecification<int>(left, right);
+ }
+
+ context c = () =>
+ {
+ left = an<Specification<int>>();
+ right = an<Specification<int>>();
+ };
+
+ static protected Specification<int> left;
+ static protected Specification<int> right;
+ }
+
+ [Concern(typeof (OrSpecification<>))]
+ public class when_one_of_the_conditions_is_met : when_checking_if_one_of_two_conditions_are_met
+ {
+ it should_return_true = () => result.should_be_true();
+
+ context c = () => when_the(left).is_told_to(x => x.is_satisfied_by(1)).it_will_return(true);
+
+ because b = () =>
+ {
+ result = sut.is_satisfied_by(1);
+ };
+
+ static bool result;
+ }
+
+ [Concern(typeof (OrSpecification<>))]
+ public class when_the_second_condition_is_met : when_checking_if_one_of_two_conditions_are_met
+ {
+ it should_return_true = () => result.should_be_true();
+
+ context c = () => when_the(right).is_told_to(x => x.is_satisfied_by(1)).it_will_return(true);
+
+ because b = () =>
+ {
+ result = sut.is_satisfied_by(1);
+ };
+
+ static bool result;
+ }
+
+ [Concern(typeof (OrSpecification<>))]
+ public class when_neither_conditions_are_met : when_checking_if_one_of_two_conditions_are_met
+ {
+ it should_return_false = () => result.should_be_false();
+
+ because b = () =>
+ {
+ result = sut.is_satisfied_by(1);
+ };
+
+ static bool result;
+ }
+ }
+}
\ No newline at end of file
product/Gorilla.Commons.Utility/ParameterizedCommand.cs
@@ -0,0 +1,7 @@
+namespace gorilla.commons.utility
+{
+ public interface ParameterizedCommand<T>
+ {
+ void run(T item);
+ }
+}
\ No newline at end of file
product/Gorilla.Commons.Utility/Parser.cs
@@ -0,0 +1,7 @@
+namespace gorilla.commons.utility
+{
+ public interface Parser<T>
+ {
+ T parse();
+ }
+}
\ No newline at end of file
product/Gorilla.Commons.Utility/Core/PredicateSpecification.cs → product/Gorilla.Commons.Utility/PredicateSpecification.cs
@@ -1,8 +1,8 @@
using System;
-namespace Gorilla.Commons.Utility.Core
+namespace gorilla.commons.utility
{
- public class PredicateSpecification<T> : ISpecification<T>
+ public class PredicateSpecification<T> : Specification<T>
{
readonly Predicate<T> criteria;
product/Gorilla.Commons.Utility/PredicateSpecificationSpecs.cs
@@ -0,0 +1,20 @@
+using developwithpassion.bdd.contexts;
+using Gorilla.Commons.Testing;
+
+namespace gorilla.commons.utility
+{
+ public class PredicateSpecificationSpecs
+ {
+ [Concern(typeof (PredicateSpecification<>))]
+ public class when_checking_if_a_criteria_is_met_and_it_is : concerns
+ {
+ it should_return_true = () => new PredicateSpecification<int>(x => true).is_satisfied_by(1).should_be_true();
+ }
+
+ [Concern(typeof (PredicateSpecification<>))]
+ public class when_checking_if_a_criteria_is_met_and_it_is_not : concerns
+ {
+ it should_return_true = () => new PredicateSpecification<int>(x => false).is_satisfied_by(1).should_be_false();
+ }
+ }
+}
\ No newline at end of file
product/Gorilla.Commons.Utility/Query.cs
@@ -0,0 +1,12 @@
+namespace gorilla.commons.utility
+{
+ public interface Query<TOutput>
+ {
+ TOutput fetch();
+ }
+
+ public interface Query<TInput, TOutput>
+ {
+ TOutput fetch(TInput item);
+ }
+}
\ No newline at end of file
product/Gorilla.Commons.Utility/Registry.cs
@@ -0,0 +1,9 @@
+using System.Collections.Generic;
+
+namespace gorilla.commons.utility
+{
+ public interface Registry<T> : IEnumerable<T>
+ {
+ IEnumerable<T> all();
+ }
+}
\ No newline at end of file
product/Gorilla.Commons.Utility/Extensions/RegistryExtensions.cs → product/Gorilla.Commons.Utility/RegistryExtensions.cs
@@ -1,13 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
-using Gorilla.Commons.Utility.Core;
-namespace Gorilla.Commons.Utility.Extensions
+namespace gorilla.commons.utility
{
public static class RegistryExtensions
{
- public static K find_an_implementation_of<T, K>(this IRegistry<T> registry) where K : T
+ public static K find_an_implementation_of<T, K>(this Registry<T> registry) where K : T
{
try
{
@@ -22,7 +21,7 @@ namespace Gorilla.Commons.Utility.Extensions
}
}
- public static IEnumerable<T> sort_all_using<T>(this IRegistry<T> registry, IComparer<T> comparer)
+ public static IEnumerable<T> sort_all_using<T>(this Registry<T> registry, IComparer<T> comparer)
{
return registry.all().sorted_using(comparer);
}
product/Gorilla.Commons.Utility/Specification.cs
@@ -0,0 +1,7 @@
+namespace gorilla.commons.utility
+{
+ public interface Specification<T>
+ {
+ bool is_satisfied_by(T item);
+ }
+}
\ No newline at end of file
product/Gorilla.Commons.Utility/Extensions/SpecificationExtensions.cs → product/Gorilla.Commons.Utility/SpecificationExtensions.cs
@@ -1,39 +1,38 @@
using System;
using System.Collections.Generic;
-using Gorilla.Commons.Utility.Core;
-namespace Gorilla.Commons.Utility.Extensions
+namespace gorilla.commons.utility
{
- public static class SpecificationExtensions
+ static public class SpecificationExtensions
{
- public static IEnumerable<T> that_satisfy<T>(this IEnumerable<T> items_to_peek_in_to,
+ static public IEnumerable<T> that_satisfy<T>(this IEnumerable<T> items_to_peek_in_to,
Predicate<T> criteria_to_satisfy)
{
foreach (var item in items_to_peek_in_to ?? new List<T>())
if (item.satisfies(criteria_to_satisfy)) yield return item;
}
- public static bool satisfies<T>(this T item_to_interrogate, Predicate<T> criteria_to_satisfy)
+ static public bool satisfies<T>(this T item_to_interrogate, Predicate<T> criteria_to_satisfy)
{
return criteria_to_satisfy(item_to_interrogate);
}
- public static bool satisfies<T>(this T item_to_validate, ISpecification<T> criteria_to_satisfy)
+ static public bool satisfies<T>(this T item_to_validate, Specification<T> criteria_to_satisfy)
{
return item_to_validate.satisfies(criteria_to_satisfy.is_satisfied_by);
}
- public static ISpecification<T> and<T>(this ISpecification<T> left, ISpecification<T> right)
+ static public Specification<T> and<T>(this Specification<T> left, Specification<T> right)
{
return new PredicateSpecification<T>(x => left.is_satisfied_by(x) && right.is_satisfied_by(x));
}
- public static ISpecification<T> or<T>(this ISpecification<T> left, ISpecification<T> right)
+ static public Specification<T> or<T>(this Specification<T> left, Specification<T> right)
{
return new PredicateSpecification<T>(x => left.is_satisfied_by(x) || right.is_satisfied_by(x));
}
- public static ISpecification<T> not<T>(this ISpecification<T> original)
+ static public Specification<T> not<T>(this Specification<T> original)
{
return new PredicateSpecification<T>(x => !original.is_satisfied_by(x));
}
product/Gorilla.Commons.Utility/SpecificationExtensionsSpecs.cs
@@ -0,0 +1,78 @@
+using developwithpassion.bdd.contexts;
+using Gorilla.Commons.Testing;
+
+namespace gorilla.commons.utility
+{
+ public class SpecificationExtensionsSpecs
+ {
+ public abstract class when_evaluating_two_conditions : concerns
+ {
+ context c = () =>
+ {
+ left = an<Specification<int>>();
+ right = an<Specification<int>>();
+ };
+
+ static protected Specification<int> left;
+ static protected Specification<int> right;
+ }
+
+ [Concern(typeof (SpecificationExtensions))]
+ public class when_checking_if_two_conditions_are_met_and_they_are : when_evaluating_two_conditions
+ {
+ it should_return_true = () => result.should_be_true();
+
+ context c = () =>
+ {
+ when_the(right).is_told_to(x => x.is_satisfied_by(1)).it_will_return(true);
+ when_the(left).is_told_to(x => x.is_satisfied_by(1)).it_will_return(true);
+ };
+
+ because b = () =>
+ {
+ result = left.or(right).is_satisfied_by(1);
+ };
+
+ static bool result;
+ }
+
+ [Concern(typeof (SpecificationExtensions))]
+ public class when_checking_if_one_of_two_conditions_are_met_and_the_left_one_is_not : when_evaluating_two_conditions
+ {
+ it should_return_true = () => result.should_be_true();
+
+ context c = () =>
+ {
+ when_the(right).is_told_to(x => x.is_satisfied_by(1)).it_will_return(true);
+ when_the(left).is_told_to(x => x.is_satisfied_by(1)).it_will_return(false);
+ };
+
+ because b = () =>
+ {
+ result = left.or(right).is_satisfied_by(1);
+ };
+
+ static bool result;
+ }
+
+ [Concern(typeof (SpecificationExtensions))]
+ public class when_checking_if_one_of_two_conditions_are_met_and_the_right_one_is_not :
+ when_evaluating_two_conditions
+ {
+ it should_return_true = () => result.should_be_true();
+
+ context c = () =>
+ {
+ when_the(right).is_told_to(x => x.is_satisfied_by(1)).it_will_return(false);
+ when_the(left).is_told_to(x => x.is_satisfied_by(1)).it_will_return(true);
+ };
+
+ because b = () =>
+ {
+ result = left.or(right).is_satisfied_by(1);
+ };
+
+ static bool result;
+ }
+ }
+}
\ No newline at end of file
product/Gorilla.Commons.Utility/State.cs
@@ -0,0 +1,6 @@
+namespace gorilla.commons.utility
+{
+ public interface State
+ {
+ }
+}
\ No newline at end of file
product/Gorilla.Commons.Utility/Extensions/StringExtensions.cs → product/Gorilla.Commons.Utility/StringExtensions.cs
@@ -1,23 +1,23 @@
-namespace Gorilla.Commons.Utility.Extensions
+namespace gorilla.commons.utility
{
- public static class StringExtensions
+ static public class StringExtensions
{
- public static string formatted_using(this string formatted_string, params object[] arguments)
+ static public string formatted_using(this string formatted_string, params object[] arguments)
{
return string.Format(formatted_string, arguments);
}
- public static bool is_equal_to_ignoring_case(this string left, string right)
+ static public bool is_equal_to_ignoring_case(this string left, string right)
{
return string.Compare(left, right, true) == 0;
}
- public static bool is_blank(this string message)
+ static public bool is_blank(this string message)
{
return string.IsNullOrEmpty(message);
}
- public static string to_string<T>(this T item)
+ static public string to_string<T>(this T item)
{
return "{0}".formatted_using(item);
}
product/Gorilla.Commons.Utility/SubjectOf.cs
@@ -0,0 +1,7 @@
+namespace gorilla.commons.utility
+{
+ public interface SubjectOf<State> where State : utility.State
+ {
+ void change_state_to(State new_state);
+ }
+}
\ No newline at end of file
product/Gorilla.Commons.Utility/Extensions/TypeExtensions.cs → product/Gorilla.Commons.Utility/TypeExtensions.cs
@@ -2,7 +2,7 @@ using System;
using System.Linq;
using System.Reflection;
-namespace Gorilla.Commons.Utility.Extensions
+namespace gorilla.commons.utility
{
public static class TypeExtensions
{
product/Gorilla.Commons.Utility/TypeExtensionsSpecs.cs
@@ -0,0 +1,39 @@
+using developwithpassion.bdd.contexts;
+using Gorilla.Commons.Testing;
+
+namespace gorilla.commons.utility
+{
+ public class TypeExtensionsSpecs
+ {
+ [Concern(typeof (TypeExtensions))]
+ public class when_getting_the_last_interface_for_a_type : concerns
+ {
+ it should_return_the_correct_one =
+ () => typeof (TestType).last_interface().should_be_equal_to(typeof (ITestType));
+ }
+
+ [Concern(typeof (TypeExtensions))]
+ public class when_getting_the_first_interface_for_a_type : concerns
+ {
+ it should_return_the_correct_one = () => typeof (TestType).first_interface().should_be_equal_to(typeof (IBase));
+ }
+
+ [Concern(typeof (TypeExtensions))]
+ public class when_checking_if_a_type_represents_a_generic_type_definition : concerns
+ {
+ it should_tell_the_truth = () =>
+ {
+ typeof (Registry<>).is_a_generic_type().should_be_true();
+ typeof (Registry<int>).is_a_generic_type().should_be_false();
+ };
+ }
+
+ public interface IBase {}
+
+ public class BaseType : IBase {}
+
+ public interface ITestType {}
+
+ public class TestType : BaseType, ITestType {}
+ }
+}
\ No newline at end of file
product/Gorilla.Commons.Utility/Gorilla.Commons.Utility.csproj → product/Gorilla.Commons.Utility/utility.csproj
@@ -8,8 +8,8 @@
<ProjectGuid>{DD8FD29E-7424-415C-9BA3-7D9F6ECBA161}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
- <RootNamespace>Gorilla.Commons.Utility</RootNamespace>
- <AssemblyName>Gorilla.Commons.Utility</AssemblyName>
+ <RootNamespace>gorilla.commons.utility</RootNamespace>
+ <AssemblyName>gorilla.commons.utility</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
@@ -58,71 +58,71 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Clock.cs" />
- <Compile Include="Core\ActionCommand.cs" />
- <Compile Include="Core\AndSpecification.cs" />
- <Compile Include="Core\AnonymousDisposable.cs" />
- <Compile Include="Core\ChainedCommand.cs" />
- <Compile Include="Core\ChainedConfiguration.cs" />
- <Compile Include="Core\ChainedMapper.cs" />
- <Compile Include="Core\DisposableCommand.cs" />
- <Compile Include="Core\EmptyCallback.cs" />
- <Compile Include="Core\EmptyCommand.cs" />
- <Compile Include="Core\ComponentFactory.cs" />
- <Compile Include="Core\Factory.cs" />
- <Compile Include="Core\FilteredVisitor.cs" />
- <Compile Include="Core\FuncSpecification.cs" />
- <Compile Include="Core\IBuilder.cs" />
- <Compile Include="Core\ICallback.cs" />
- <Compile Include="Core\ICallbackCommand.cs" />
- <Compile Include="Core\ICommand.cs" />
- <Compile Include="Core\IConfiguration.cs" />
- <Compile Include="Core\Id.cs" />
- <Compile Include="Core\IDisposableCommand.cs" />
- <Compile Include="Core\IFactory.cs" />
- <Compile Include="Core\IIdentifiable.cs" />
- <Compile Include="Core\IImport.cs" />
- <Compile Include="Core\IMapper.cs" />
- <Compile Include="Core\INotification.cs" />
- <Compile Include="Core\IParameterizedCommand.cs" />
- <Compile Include="Core\IParser.cs" />
- <Compile Include="Core\IQuery.cs" />
- <Compile Include="Core\IRegistry.cs" />
- <Compile Include="Core\ISpecification.cs" />
- <Compile Include="Core\IState.cs" />
- <Compile Include="Core\IStateContext.cs" />
- <Compile Include="Core\IValueReturningVisitor.cs" />
- <Compile Include="Core\IVisitable.cs" />
- <Compile Include="Core\IVisitor.cs" />
- <Compile Include="Core\Mapper.cs" />
- <Compile Include="Core\NotificationMessage.cs" />
- <Compile Include="Core\NotSpecification.cs" />
- <Compile Include="Core\NotSpecificationSpecs.cs" />
- <Compile Include="Core\OrSpecification.cs" />
- <Compile Include="Core\OrSpecificationSpecs.cs" />
- <Compile Include="Core\PredicateSpecification.cs" />
- <Compile Include="Core\PredicateSpecificationSpecs.cs" />
+ <Compile Include="AnonymousCommand.cs" />
+ <Compile Include="AndSpecification.cs" />
+ <Compile Include="AnonymousDisposable.cs" />
+ <Compile Include="ChainedCommand.cs" />
+ <Compile Include="ChainedConfiguration.cs" />
+ <Compile Include="ChainedMapper.cs" />
+ <Compile Include="EmptyCallback.cs" />
+ <Compile Include="EmptyCommand.cs" />
+ <Compile Include="DefaultConstructorFactory.cs" />
+ <Compile Include="FactoryDelegate.cs" />
+ <Compile Include="FilteredVisitor.cs" />
+ <Compile Include="FuncSpecification.cs" />
+ <Compile Include="Builder.cs" />
+ <Compile Include="Callback.cs" />
+ <Compile Include="CallbackCommand.cs" />
+ <Compile Include="Command.cs" />
+ <Compile Include="Configuration.cs" />
+ <Compile Include="ComponentFactory.cs" />
+ <Compile Include="Id.cs" />
+ <Compile Include="DisposableCommand.cs" />
+ <Compile Include="Factory.cs" />
+ <Compile Include="Identifiable.cs" />
+ <Compile Include="Import.cs" />
+ <Compile Include="Mapper.cs" />
+ <Compile Include="Notification.cs" />
+ <Compile Include="ParameterizedCommand.cs" />
+ <Compile Include="Parser.cs" />
+ <Compile Include="Query.cs" />
+ <Compile Include="Registry.cs" />
+ <Compile Include="Specification.cs" />
+ <Compile Include="State.cs" />
+ <Compile Include="SubjectOf.cs" />
+ <Compile Include="ValueReturningVisitor.cs" />
+ <Compile Include="Visitable.cs" />
+ <Compile Include="Visitor.cs" />
+ <Compile Include="AnonymousMapper.cs" />
+ <Compile Include="NotificationMessage.cs" />
+ <Compile Include="NotSpecification.cs" />
+ <Compile Include="NotSpecificationSpecs.cs" />
+ <Compile Include="OrSpecification.cs" />
+ <Compile Include="OrSpecificationSpecs.cs" />
+ <Compile Include="PredicateSpecification.cs" />
+ <Compile Include="PredicateSpecificationSpecs.cs" />
<Compile Include="Date.cs" />
<Compile Include="DateSpecs.cs" />
- <Compile Include="Extensions\CommandExtensions.cs" />
- <Compile Include="Extensions\ConfigurationExtensions.cs" />
- <Compile Include="Extensions\ConfigurationExtensionsSpecs.cs" />
- <Compile Include="Extensions\ConversionExtensions.cs" />
- <Compile Include="Extensions\EnumerableExtensions.cs" />
- <Compile Include="Extensions\EnumerableExtensionsSpecs.cs" />
- <Compile Include="Extensions\FuncExtensions.cs" />
- <Compile Include="Extensions\ListExtensions.cs" />
- <Compile Include="Extensions\ListExtensionsSpecs.cs" />
- <Compile Include="Extensions\MappingExtensions.cs" />
- <Compile Include="Extensions\MappingExtensionsSpecs.cs" />
- <Compile Include="Extensions\NumericConversions.cs" />
- <Compile Include="Extensions\NumericConversionsSpecs.cs" />
- <Compile Include="Extensions\RegistryExtensions.cs" />
- <Compile Include="Extensions\SpecificationExtensionsSpecs.cs" />
- <Compile Include="Extensions\SpecificationExtensions.cs" />
- <Compile Include="Extensions\StringExtensions.cs" />
- <Compile Include="Extensions\TypeExtensions.cs" />
- <Compile Include="Extensions\TypeExtensionsSpecs.cs" />
- <Compile Include="Extensions\VisitorExtensions.cs" />
+ <Compile Include="CommandExtensions.cs" />
+ <Compile Include="ConfigurationExtensions.cs" />
+ <Compile Include="ConfigurationExtensionsSpecs.cs" />
+ <Compile Include="ConversionExtensions.cs" />
+ <Compile Include="EnumerableExtensions.cs" />
+ <Compile Include="EnumerableExtensionsSpecs.cs" />
+ <Compile Include="FuncExtensions.cs" />
+ <Compile Include="ListExtensions.cs" />
+ <Compile Include="ListExtensionsSpecs.cs" />
+ <Compile Include="MappingExtensions.cs" />
+ <Compile Include="MappingExtensionsSpecs.cs" />
+ <Compile Include="NumericConversions.cs" />
+ <Compile Include="NumericConversionsSpecs.cs" />
+ <Compile Include="RegistryExtensions.cs" />
+ <Compile Include="SpecificationExtensionsSpecs.cs" />
+ <Compile Include="SpecificationExtensions.cs" />
+ <Compile Include="StringExtensions.cs" />
+ <Compile Include="TypeExtensions.cs" />
+ <Compile Include="TypeExtensionsSpecs.cs" />
+ <Compile Include="VisitorExtensions.cs" />
<Compile Include="Percent.cs" />
<Compile Include="PercentSpecs.cs" />
<Compile Include="Year.cs" />
product/Gorilla.Commons.Utility/ValueReturningVisitor.cs
@@ -0,0 +1,8 @@
+namespace gorilla.commons.utility
+{
+ public interface ValueReturningVisitor<Value, T> : Visitor<T>
+ {
+ Value value { get; }
+ void reset();
+ }
+}
\ No newline at end of file
product/Gorilla.Commons.Utility/Visitable.cs
@@ -0,0 +1,7 @@
+namespace gorilla.commons.utility
+{
+ public interface Visitable<T>
+ {
+ void accept(Visitor<T> visitor);
+ }
+}
\ No newline at end of file
product/Gorilla.Commons.Utility/Visitor.cs
@@ -0,0 +1,7 @@
+namespace gorilla.commons.utility
+{
+ public interface Visitor<T>
+ {
+ void visit(T item_to_visit);
+ }
+}
\ No newline at end of file
product/Gorilla.Commons.Utility/VisitorExtensions.cs
@@ -0,0 +1,19 @@
+using System.Collections.Generic;
+
+namespace gorilla.commons.utility
+{
+ static public class VisitorExtensions
+ {
+ static public Result return_value_from_visiting_all_with<Result, T>(this IEnumerable<T> items, ValueReturningVisitor<Result, T> visitor)
+ {
+ visitor.reset();
+ items.vist_all_with(visitor);
+ return visitor.value;
+ }
+
+ static public void vist_all_with<T>(this IEnumerable<T> items, Visitor<T> visitor)
+ {
+ items.each(visitor.visit);
+ }
+ }
+}
\ No newline at end of file
product/Gorilla.Commons.Windows.Forms/Gorilla.Commons.Windows.Forms.csproj
@@ -1,86 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProductVersion>9.0.30729</ProductVersion>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{54B55B2B-A58F-45DF-A446-234C9D70DC0B}</ProjectGuid>
- <OutputType>Library</OutputType>
- <AppDesignerFolder>Properties</AppDesignerFolder>
- <RootNamespace>Gorilla.Commons.Windows.Forms</RootNamespace>
- <AssemblyName>Gorilla.Commons.Windows.Forms</AssemblyName>
- <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
- <FileAlignment>512</FileAlignment>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- <DebugSymbols>true</DebugSymbols>
- <DebugType>full</DebugType>
- <Optimize>false</Optimize>
- <OutputPath>bin\Debug\</OutputPath>
- <DefineConstants>DEBUG;TRACE</DefineConstants>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- <OutputPath>bin\Release\</OutputPath>
- <DefineConstants>TRACE</DefineConstants>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- </PropertyGroup>
- <ItemGroup>
- <Reference Include="bdddoc, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\build\lib\test\bdd.doc\bdddoc.dll</HintPath>
- </Reference>
- <Reference Include="developwithpassion.bdd, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\build\lib\test\developwithpassion\developwithpassion.bdd.dll</HintPath>
- </Reference>
- <Reference Include="Rhino.Mocks, Version=3.5.0.1337, Culture=neutral, PublicKeyToken=0b3305902db7183f, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\build\lib\test\rhino.mocks\Rhino.Mocks.dll</HintPath>
- </Reference>
- <Reference Include="System" />
- <Reference Include="System.Core">
- <RequiredTargetFramework>3.5</RequiredTargetFramework>
- </Reference>
- <Reference Include="System.Drawing" />
- <Reference Include="System.Windows.Forms" />
- <Reference Include="System.Xml.Linq">
- <RequiredTargetFramework>3.5</RequiredTargetFramework>
- </Reference>
- <Reference Include="System.Data.DataSetExtensions">
- <RequiredTargetFramework>3.5</RequiredTargetFramework>
- </Reference>
- <Reference Include="System.Data" />
- <Reference Include="System.Xml" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="..\Gorilla.Commons.Infrastructure\Gorilla.Commons.Infrastructure.csproj">
- <Project>{AA5EEED9-4531-45F7-AFCD-AD9717D2E405}</Project>
- <Name>Gorilla.Commons.Infrastructure</Name>
- </ProjectReference>
- <ProjectReference Include="..\Gorilla.Commons.Testing\Gorilla.Commons.Testing.csproj">
- <Project>{44E65096-9657-4716-90F8-4535BABE8039}</Project>
- <Name>Gorilla.Commons.Testing</Name>
- </ProjectReference>
- <ProjectReference Include="..\Gorilla.Commons.Utility\Gorilla.Commons.Utility.csproj">
- <Project>{DD8FD29E-7424-415C-9BA3-7D9F6ECBA161}</Project>
- <Name>Gorilla.Commons.Utility</Name>
- </ProjectReference>
- </ItemGroup>
- <ItemGroup>
- <Folder Include="Properties\" />
- </ItemGroup>
- <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
- <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
- Other similar extension points exist, see Microsoft.Common.targets.
- <Target Name="BeforeBuild">
- </Target>
- <Target Name="AfterBuild">
- </Target>
- -->
-</Project>
\ No newline at end of file
product/Gorilla.Commons.Windows.Forms.ThirdParty/Gorilla.Commons.Windows.Forms.ThirdParty.csproj
@@ -1,73 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProductVersion>9.0.30729</ProductVersion>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{8050731D-48B2-4636-9D1C-2B6D052F39DC}</ProjectGuid>
- <OutputType>Library</OutputType>
- <AppDesignerFolder>Properties</AppDesignerFolder>
- <RootNamespace>Gorilla.Commons.Windows.Forms</RootNamespace>
- <AssemblyName>Gorilla.Commons.Windows.Forms.ThirdParty</AssemblyName>
- <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
- <FileAlignment>512</FileAlignment>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- <DebugSymbols>true</DebugSymbols>
- <DebugType>full</DebugType>
- <Optimize>false</Optimize>
- <OutputPath>bin\Debug\</OutputPath>
- <DefineConstants>DEBUG;TRACE</DefineConstants>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- <OutputPath>bin\Release\</OutputPath>
- <DefineConstants>TRACE</DefineConstants>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- </PropertyGroup>
- <ItemGroup>
- <Reference Include="ComponentFactory.Krypton.Toolkit, Version=3.0.8.0, Culture=neutral, PublicKeyToken=a87e673e9ecb6e8e, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\build\lib\app\component.factory\ComponentFactory.Krypton.Toolkit.dll</HintPath>
- </Reference>
- <Reference Include="System" />
- <Reference Include="System.Core">
- <RequiredTargetFramework>3.5</RequiredTargetFramework>
- </Reference>
- <Reference Include="System.Windows.Forms" />
- <Reference Include="System.Xml.Linq">
- <RequiredTargetFramework>3.5</RequiredTargetFramework>
- </Reference>
- <Reference Include="System.Data.DataSetExtensions">
- <RequiredTargetFramework>3.5</RequiredTargetFramework>
- </Reference>
- <Reference Include="System.Data" />
- <Reference Include="System.Xml" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="..\Gorilla.Commons.Utility\Gorilla.Commons.Utility.csproj">
- <Project>{DD8FD29E-7424-415C-9BA3-7D9F6ECBA161}</Project>
- <Name>Gorilla.Commons.Utility</Name>
- </ProjectReference>
- <ProjectReference Include="..\Gorilla.Commons.Windows.Forms\Gorilla.Commons.Windows.Forms.csproj">
- <Project>{54B55B2B-A58F-45DF-A446-234C9D70DC0B}</Project>
- <Name>Gorilla.Commons.Windows.Forms</Name>
- </ProjectReference>
- </ItemGroup>
- <ItemGroup>
- <Folder Include="Properties\" />
- </ItemGroup>
- <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
- <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
- Other similar extension points exist, see Microsoft.Common.targets.
- <Target Name="BeforeBuild">
- </Target>
- <Target Name="AfterBuild">
- </Target>
- -->
-</Project>
\ No newline at end of file
solution.sln
@@ -9,7 +9,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gorilla.Commons.Infrastruct
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gorilla.Commons.Build", "build\Gorilla.Commons.Build.csproj", "{B8505B10-85C7-45F4-B039-D364DD556D7D}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gorilla.Commons.Utility", "product\Gorilla.Commons.Utility\Gorilla.Commons.Utility.csproj", "{DD8FD29E-7424-415C-9BA3-7D9F6ECBA161}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "utility", "product\Gorilla.Commons.Utility\utility.csproj", "{DD8FD29E-7424-415C-9BA3-7D9F6ECBA161}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution