Commit a0b6397
Changed files (108)
build
product
infrastructure
debugging
filesystem
proxies
registries
testing
unit
infrastructure
cloning
container
logging
proxies
registries
utility
utility
build/project.build
@@ -1,9 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
- <project name="gorilla.commons">
- <property name="project.name" value="${project::get-name()}" />
-
+<project name="gorilla.commons" default="test">
<property name="base.dir" value="${directory::get-parent-directory(project::get-base-directory())}" />
- <property name="product.dir" value="${base.dir}\product" />
<property name="build.dir" value="${base.dir}\build" />
<property name="build.tools.dir" value="${build.dir}\tools" />
product/infrastructure/cloning/BinarySerializer.cs
@@ -1,11 +1,11 @@
-using System.Runtime.Serialization.Formatters.Binary;
-
-namespace Gorilla.Commons.Infrastructure.Cloning
-{
- public class BinarySerializer<T> : FileStreamSerializer<T>
- {
- public BinarySerializer(string file_path) : base(file_path, new BinaryFormatter())
- {
- }
- }
+using System.Runtime.Serialization.Formatters.Binary;
+
+namespace gorilla.infrastructure.cloning
+{
+ public class BinarySerializer<T> : FileStreamSerializer<T>
+ {
+ public BinarySerializer(string file_path) : base(file_path, new BinaryFormatter())
+ {
+ }
+ }
}
\ No newline at end of file
product/infrastructure/cloning/FileStreamSerializer.cs
@@ -1,34 +1,34 @@
-using System.IO;
-using System.Runtime.Serialization;
-
-namespace Gorilla.Commons.Infrastructure.Cloning
-{
- public class FileStreamSerializer<T> : Serializer<T>
- {
- public FileStreamSerializer(string file_path, IFormatter formatter)
- {
- this.file_path = file_path;
- this.formatter = formatter;
- }
-
- public void serialize(T to_serialize)
- {
- using (var stream = new FileStream(file_path, FileMode.Create, FileAccess.Write))
- formatter.Serialize(stream, to_serialize);
- }
-
- public T deserialize()
- {
- using (var stream = new FileStream(file_path, FileMode.Open, FileAccess.Read))
- return (T) formatter.Deserialize(stream);
- }
-
- public void Dispose()
- {
- File.Delete(file_path);
- }
-
- readonly string file_path;
- readonly IFormatter formatter;
- }
+using System.IO;
+using System.Runtime.Serialization;
+
+namespace gorilla.infrastructure.cloning
+{
+ public class FileStreamSerializer<T> : Serializer<T>
+ {
+ public FileStreamSerializer(string file_path, IFormatter formatter)
+ {
+ this.file_path = file_path;
+ this.formatter = formatter;
+ }
+
+ public void serialize(T to_serialize)
+ {
+ using (var stream = new FileStream(file_path, FileMode.Create, FileAccess.Write))
+ formatter.Serialize(stream, to_serialize);
+ }
+
+ public T deserialize()
+ {
+ using (var stream = new FileStream(file_path, FileMode.Open, FileAccess.Read))
+ return (T) formatter.Deserialize(stream);
+ }
+
+ public void Dispose()
+ {
+ File.Delete(file_path);
+ }
+
+ readonly string file_path;
+ readonly IFormatter formatter;
+ }
}
\ No newline at end of file
product/infrastructure/cloning/Prototype.cs
@@ -1,21 +1,21 @@
-using System.IO;
-
-namespace Gorilla.Commons.Infrastructure.Cloning
-{
- public interface IPrototype
- {
- T clone<T>(T item);
- }
-
- public class Prototype : IPrototype
- {
- public T clone<T>(T item)
- {
- using (var serializer = new BinarySerializer<T>(Path.GetTempFileName()))
- {
- serializer.serialize(item);
- return serializer.deserialize();
- }
- }
- }
+using System.IO;
+
+namespace gorilla.infrastructure.cloning
+{
+ public interface IPrototype
+ {
+ T clone<T>(T item);
+ }
+
+ public class Prototype : IPrototype
+ {
+ public T clone<T>(T item)
+ {
+ using (var serializer = new BinarySerializer<T>(Path.GetTempFileName()))
+ {
+ serializer.serialize(item);
+ return serializer.deserialize();
+ }
+ }
+ }
}
\ No newline at end of file
product/infrastructure/cloning/Serializer.cs
@@ -1,10 +1,10 @@
-using System;
-
-namespace Gorilla.Commons.Infrastructure.Cloning
-{
- public interface Serializer<T> : IDisposable
- {
- void serialize(T to_serialize);
- T deserialize();
- }
+using System;
+
+namespace gorilla.infrastructure.cloning
+{
+ public interface Serializer<T> : IDisposable
+ {
+ void serialize(T to_serialize);
+ T deserialize();
+ }
}
\ No newline at end of file
product/infrastructure/container/DependencyRegistry.cs
@@ -1,10 +1,10 @@
-using System.Collections.Generic;
-
-namespace Gorilla.Commons.Infrastructure.Container
-{
- public interface DependencyRegistry
- {
- Contract get_a<Contract>();
- IEnumerable<Contract> get_all<Contract>();
- }
+using System.Collections.Generic;
+
+namespace gorilla.infrastructure.container
+{
+ public interface DependencyRegistry
+ {
+ Contract get_a<Contract>();
+ IEnumerable<Contract> get_all<Contract>();
+ }
}
\ No newline at end of file
product/infrastructure/container/DependencyResolutionException.cs
@@ -1,13 +1,13 @@
-using System;
-using gorilla.commons.utility;
-
-namespace Gorilla.Commons.Infrastructure.Container
-{
- public class DependencyResolutionException<T> : Exception
- {
- public DependencyResolutionException(Exception inner_exception)
- : base("Could not resolve {0}".formatted_using(typeof (T).FullName), inner_exception)
- {
- }
- }
+using System;
+using gorilla.utility;
+
+namespace gorilla.infrastructure.container
+{
+ public class DependencyResolutionException<T> : Exception
+ {
+ public DependencyResolutionException(Exception inner_exception)
+ : base("Could not resolve {0}".formatted_using(typeof (T).FullName), inner_exception)
+ {
+ }
+ }
}
\ No newline at end of file
product/infrastructure/container/Resolve.cs
@@ -1,33 +1,33 @@
-using System;
-
-namespace Gorilla.Commons.Infrastructure.Container
-{
- static public class Resolve
- {
- static DependencyRegistry underlying_registry;
- static bool initialized;
-
- static public void initialize_with(DependencyRegistry registry)
- {
- underlying_registry = registry;
- initialized = registry != null;
- }
-
- static public DependencyToResolve the<DependencyToResolve>()
- {
- try
- {
- return underlying_registry.get_a<DependencyToResolve>();
- }
- catch (Exception e)
- {
- throw new DependencyResolutionException<DependencyToResolve>(e);
- }
- }
-
- static public bool is_initialized()
- {
- return initialized;
- }
- }
+using System;
+
+namespace gorilla.infrastructure.container
+{
+ static public class Resolve
+ {
+ static DependencyRegistry underlying_registry;
+ static bool initialized;
+
+ static public void initialize_with(DependencyRegistry registry)
+ {
+ underlying_registry = registry;
+ initialized = registry != null;
+ }
+
+ static public DependencyToResolve the<DependencyToResolve>()
+ {
+ try
+ {
+ return underlying_registry.get_a<DependencyToResolve>();
+ }
+ catch (Exception e)
+ {
+ throw new DependencyResolutionException<DependencyToResolve>(e);
+ }
+ }
+
+ static public bool is_initialized()
+ {
+ return initialized;
+ }
+ }
}
\ No newline at end of file
product/infrastructure/debugging/Launch.cs
@@ -1,15 +0,0 @@
-using System.Diagnostics;
-
-namespace Gorilla.Commons.Infrastructure.Debugging
-{
- static public class Launch
- {
- static public void the_debugger()
- {
-#if DEBUG
- if (Debugger.IsAttached) Debugger.Break();
- else Debugger.Launch();
-#endif
- }
- }
-}
\ No newline at end of file
product/infrastructure/filesystem/ApplicationFile.cs
@@ -1,62 +0,0 @@
-namespace Gorilla.Commons.Infrastructure.FileSystem
-{
- public class ApplicationFile : File
- {
- public ApplicationFile(string path)
- {
- this.path = path;
- }
-
- public virtual string path { get; private set; }
-
- public virtual bool does_the_file_exist()
- {
- return !string.IsNullOrEmpty(path) && System.IO.File.Exists(path);
- }
-
- public void copy_to(string other_path)
- {
- System.IO.File.Copy(path, other_path, true);
- }
-
- public void delete()
- {
- System.IO.File.Delete(path);
- }
-
- public static implicit operator ApplicationFile(string file_path)
- {
- return new ApplicationFile(file_path);
- }
-
- public static implicit operator string(ApplicationFile file)
- {
- return file.path;
- }
-
- public bool Equals(ApplicationFile other)
- {
- if (ReferenceEquals(null, other)) return false;
- if (ReferenceEquals(this, other)) return true;
- return Equals(other.path, path);
- }
-
- public override bool Equals(object obj)
- {
- if (ReferenceEquals(null, obj)) return false;
- if (ReferenceEquals(this, obj)) return true;
- if (obj.GetType() != typeof (ApplicationFile)) return false;
- return Equals((ApplicationFile) obj);
- }
-
- public override int GetHashCode()
- {
- return (path != null ? path.GetHashCode() : 0);
- }
-
- public override string ToString()
- {
- return path;
- }
- }
-}
\ No newline at end of file
product/infrastructure/filesystem/File.cs
@@ -1,10 +0,0 @@
-namespace Gorilla.Commons.Infrastructure.FileSystem
-{
- public interface File
- {
- string path { get; }
- bool does_the_file_exist();
- void copy_to(string path);
- void delete();
- }
-}
\ No newline at end of file
product/infrastructure/logging/Log.cs
@@ -1,25 +1,25 @@
-using System;
-using Gorilla.Commons.Infrastructure.Container;
-
-namespace Gorilla.Commons.Infrastructure.Logging
-{
- static public class Log
- {
- static public Logger For<T>(T item_to_create_logger_for)
- {
- return For(typeof (T));
- }
-
- static public Logger For(Type type_to_create_a_logger_for)
- {
- try
- {
- return Resolve.the<LogFactory>().create_for(type_to_create_a_logger_for);
- }
- catch
- {
- return new TextLogger(Console.Out);
- }
- }
- }
+using System;
+using gorilla.infrastructure.container;
+
+namespace gorilla.infrastructure.logging
+{
+ static public class Log
+ {
+ static public Logger For<T>(T item_to_create_logger_for)
+ {
+ return For(typeof (T));
+ }
+
+ static public Logger For(Type type_to_create_a_logger_for)
+ {
+ try
+ {
+ return Resolve.the<LogFactory>().create_for(type_to_create_a_logger_for);
+ }
+ catch
+ {
+ return new TextLogger(Console.Out);
+ }
+ }
+ }
}
\ No newline at end of file
product/infrastructure/logging/LogFactory.cs
@@ -1,9 +1,9 @@
-using System;
-
-namespace Gorilla.Commons.Infrastructure.Logging
-{
- public interface LogFactory
- {
- Logger create_for(Type type_to_create_logger_for);
- }
+using System;
+
+namespace gorilla.infrastructure.logging
+{
+ public interface LogFactory
+ {
+ Logger create_for(Type type_to_create_logger_for);
+ }
}
\ No newline at end of file
product/infrastructure/logging/Loggable.cs
@@ -1,7 +1,7 @@
-namespace Gorilla.Commons.Infrastructure.Logging
-{
- public interface Loggable
- {
-
- }
+namespace gorilla.infrastructure.logging
+{
+ public interface Loggable
+ {
+
+ }
}
\ No newline at end of file
product/infrastructure/logging/Logger.cs
@@ -1,11 +1,11 @@
-using System;
-
-namespace Gorilla.Commons.Infrastructure.Logging
-{
- public interface Logger
- {
- void informational(string formatted_string, params object[] arguments);
- void debug(string formatted_string, params object[] arguments);
- void error(Exception e);
- }
+using System;
+
+namespace gorilla.infrastructure.logging
+{
+ public interface Logger
+ {
+ void informational(string formatted_string, params object[] arguments);
+ void debug(string formatted_string, params object[] arguments);
+ void error(Exception e);
+ }
}
\ No newline at end of file
product/infrastructure/logging/LoggingExtensions.cs
@@ -1,17 +1,17 @@
-using System;
-
-namespace Gorilla.Commons.Infrastructure.Logging
-{
- public static class LoggingExtensions
- {
- public static Logger log<T>(this T item_to_log)
- {
- return Log.For(item_to_log);
- }
-
- public static void add_to_log(this Exception error_to_log)
- {
- Log.For(error_to_log).error(error_to_log);
- }
- }
+using System;
+
+namespace gorilla.infrastructure.logging
+{
+ public static class LoggingExtensions
+ {
+ public static Logger log<T>(this T item_to_log)
+ {
+ return Log.For(item_to_log);
+ }
+
+ public static void add_to_log(this Exception error_to_log)
+ {
+ Log.For(error_to_log).error(error_to_log);
+ }
+ }
}
\ No newline at end of file
product/infrastructure/logging/TextLogger.cs
@@ -1,33 +1,33 @@
-using System;
-using System.IO;
-using System.Threading;
-using gorilla.commons.utility;
-
-namespace Gorilla.Commons.Infrastructure.Logging
-{
- public class TextLogger : Logger
- {
- readonly TextWriter writer;
-
- public TextLogger(TextWriter writer)
- {
- this.writer = writer;
- }
-
- public void informational(string formatted_string, params object[] arguments)
- {
- writer.WriteLine(formatted_string, arguments);
- }
-
- public void debug(string formatted_string, params object[] arguments)
- {
- writer.WriteLine("[{0}] - {1}", Thread.CurrentThread.ManagedThreadId,
- formatted_string.formatted_using(arguments));
- }
-
- public void error(Exception e)
- {
- writer.WriteLine("{0}", e);
- }
- }
+using System;
+using System.IO;
+using System.Threading;
+using gorilla.utility;
+
+namespace gorilla.infrastructure.logging
+{
+ public class TextLogger : Logger
+ {
+ readonly TextWriter writer;
+
+ public TextLogger(TextWriter writer)
+ {
+ this.writer = writer;
+ }
+
+ public void informational(string formatted_string, params object[] arguments)
+ {
+ writer.WriteLine(formatted_string, arguments);
+ }
+
+ public void debug(string formatted_string, params object[] arguments)
+ {
+ writer.WriteLine("[{0}] - {1}", Thread.CurrentThread.ManagedThreadId,
+ formatted_string.formatted_using(arguments));
+ }
+
+ public void error(Exception e)
+ {
+ writer.WriteLine("{0}", e);
+ }
+ }
}
\ No newline at end of file
product/infrastructure/proxies/ExceptionExtensions.cs
@@ -1,18 +1,18 @@
-using System;
-using System.Reflection;
-
-namespace Gorilla.Commons.Infrastructure.Proxies
-{
- static public class ExceptionExtensions
- {
- static readonly MethodInfo method =
- typeof (Exception).GetMethod("InternalPreserveStackTrace",
- BindingFlags.NonPublic | BindingFlags.Instance);
-
- static public Exception preserve_stack_trace(this Exception exception)
- {
- method.Invoke(exception, new object[0]);
- return exception;
- }
- }
+using System;
+using System.Reflection;
+
+namespace gorilla.infrastructure.proxies
+{
+ static public class ExceptionExtensions
+ {
+ static readonly MethodInfo method =
+ typeof (Exception).GetMethod("InternalPreserveStackTrace",
+ BindingFlags.NonPublic | BindingFlags.Instance);
+
+ static public Exception preserve_stack_trace(this Exception exception)
+ {
+ method.Invoke(exception, new object[0]);
+ return exception;
+ }
+ }
}
\ No newline at end of file
product/infrastructure/proxies/Interceptor.cs
@@ -1,7 +1,7 @@
-namespace Gorilla.Commons.Infrastructure.Proxies
-{
- public interface Interceptor
- {
- void intercept(Invocation invocation);
- }
+namespace gorilla.infrastructure.proxies
+{
+ public interface Interceptor
+ {
+ void intercept(Invocation invocation);
+ }
}
\ No newline at end of file
product/infrastructure/proxies/Invocation.cs
@@ -1,12 +1,12 @@
-using System.Reflection;
-
-namespace Gorilla.Commons.Infrastructure.Proxies
-{
- public interface Invocation
- {
- void proceed();
- object[] arguments { get; }
- MethodInfo method { get; }
- object return_value { get; set; }
- }
+using System.Reflection;
+
+namespace gorilla.infrastructure.proxies
+{
+ public interface Invocation
+ {
+ void proceed();
+ object[] arguments { get; }
+ MethodInfo method { get; }
+ object return_value { get; set; }
+ }
}
\ No newline at end of file
product/infrastructure/proxies/MethodCallInvocation.cs
@@ -1,47 +1,47 @@
-using System.Collections.Generic;
-using System.Reflection;
-using System.Runtime.Remoting.Messaging;
-using gorilla.commons.utility;
-
-namespace Gorilla.Commons.Infrastructure.Proxies
-{
- public class MethodCallInvocation<T> : Invocation
- {
- readonly IMethodCallMessage call;
- readonly T target;
- readonly Stack<Interceptor> interceptors;
-
- public MethodCallInvocation(IEnumerable<Interceptor> interceptors, IMethodCallMessage call, T target)
- {
- this.call = call;
- this.target = target;
- this.interceptors = new Stack<Interceptor>(interceptors);
- arguments = call.Properties["__Args"].downcast_to<object[]>();
- method = call.MethodBase.downcast_to<MethodInfo>();
- }
-
- public object[] arguments { get; set; }
-
- public MethodInfo method { get; set; }
-
- public object return_value { get; set; }
-
- public void proceed()
- {
- if (interceptors.Count > 0)
- {
- interceptors.Pop().intercept(this);
- return;
- }
-
- try
- {
- return_value = call.MethodBase.Invoke(target, arguments);
- }
- catch (TargetInvocationException e)
- {
- throw e.InnerException.preserve_stack_trace();
- }
- }
- }
+using System.Collections.Generic;
+using System.Reflection;
+using System.Runtime.Remoting.Messaging;
+using gorilla.utility;
+
+namespace gorilla.infrastructure.proxies
+{
+ public class MethodCallInvocation<T> : Invocation
+ {
+ readonly IMethodCallMessage call;
+ readonly T target;
+ readonly Stack<Interceptor> interceptors;
+
+ public MethodCallInvocation(IEnumerable<Interceptor> interceptors, IMethodCallMessage call, T target)
+ {
+ this.call = call;
+ this.target = target;
+ this.interceptors = new Stack<Interceptor>(interceptors);
+ arguments = call.Properties["__Args"].downcast_to<object[]>();
+ method = call.MethodBase.downcast_to<MethodInfo>();
+ }
+
+ public object[] arguments { get; set; }
+
+ public MethodInfo method { get; set; }
+
+ public object return_value { get; set; }
+
+ public void proceed()
+ {
+ if (interceptors.Count > 0)
+ {
+ interceptors.Pop().intercept(this);
+ return;
+ }
+
+ try
+ {
+ return_value = call.MethodBase.Invoke(target, arguments);
+ }
+ catch (TargetInvocationException e)
+ {
+ throw e.InnerException.preserve_stack_trace();
+ }
+ }
+ }
}
\ No newline at end of file
product/infrastructure/proxies/ProxyFactory.cs
@@ -1,10 +1,10 @@
-namespace Gorilla.Commons.Infrastructure.Proxies
-{
- static public class ProxyFactory
- {
- static public T create<T>(T target, params Interceptor[] interceptors)
- {
- return new RemotingProxyFactory<T>(target, interceptors).create_proxy();
- }
- }
+namespace gorilla.infrastructure.proxies
+{
+ static public class ProxyFactory
+ {
+ static public T create<T>(T target, params Interceptor[] interceptors)
+ {
+ return new RemotingProxyFactory<T>(target, interceptors).create_proxy();
+ }
+ }
}
\ No newline at end of file
product/infrastructure/proxies/RemotingProxyFactory.cs
@@ -1,44 +1,44 @@
-using System.Collections.Generic;
-using System.Runtime.Remoting.Messaging;
-using System.Runtime.Remoting.Proxies;
-using gorilla.commons.utility;
-
-namespace Gorilla.Commons.Infrastructure.Proxies
-{
- public class RemotingProxyFactory<T> : RealProxy
- {
- readonly T target;
- readonly IEnumerable<Interceptor> interceptors;
-
- public RemotingProxyFactory(T target, IEnumerable<Interceptor> interceptors) : base(typeof (T))
- {
- this.target = target;
- this.interceptors = interceptors;
- }
-
- public override IMessage Invoke(IMessage message)
- {
- if (message.is_an_implementation_of<IMethodCallMessage>())
- {
- var call = message.downcast_to<IMethodCallMessage>();
- var invocation = new MethodCallInvocation<T>(interceptors, call, target);
- invocation.proceed();
- return return_value(invocation.return_value, invocation.arguments, call);
- }
- return null;
- }
-
- IMessage return_value(object return_value, object[] out_parameters, IMethodCallMessage call)
- {
- return new ReturnMessage(return_value,
- out_parameters,
- out_parameters == null ? 0 : out_parameters.Length,
- call.LogicalCallContext, call);
- }
-
- public T create_proxy()
- {
- return GetTransparentProxy().downcast_to<T>();
- }
- }
+using System.Collections.Generic;
+using System.Runtime.Remoting.Messaging;
+using System.Runtime.Remoting.Proxies;
+using gorilla.utility;
+
+namespace gorilla.infrastructure.proxies
+{
+ public class RemotingProxyFactory<T> : RealProxy
+ {
+ readonly T target;
+ readonly IEnumerable<Interceptor> interceptors;
+
+ public RemotingProxyFactory(T target, IEnumerable<Interceptor> interceptors) : base(typeof (T))
+ {
+ this.target = target;
+ this.interceptors = interceptors;
+ }
+
+ public override IMessage Invoke(IMessage message)
+ {
+ if (message.is_an_implementation_of<IMethodCallMessage>())
+ {
+ var call = message.downcast_to<IMethodCallMessage>();
+ var invocation = new MethodCallInvocation<T>(interceptors, call, target);
+ invocation.proceed();
+ return return_value(invocation.return_value, invocation.arguments, call);
+ }
+ return null;
+ }
+
+ IMessage return_value(object return_value, object[] out_parameters, IMethodCallMessage call)
+ {
+ return new ReturnMessage(return_value,
+ out_parameters,
+ out_parameters == null ? 0 : out_parameters.Length,
+ call.LogicalCallContext, call);
+ }
+
+ public T create_proxy()
+ {
+ return GetTransparentProxy().downcast_to<T>();
+ }
+ }
}
\ No newline at end of file
product/infrastructure/reflection/ApplicationAssembly.cs
@@ -1,20 +1,20 @@
-using System;
-using System.Collections.Generic;
-
-namespace Gorilla.Commons.Infrastructure.Reflection
-{
- public class ApplicationAssembly : Assembly
- {
- readonly System.Reflection.Assembly assembly;
-
- public ApplicationAssembly(System.Reflection.Assembly assembly)
- {
- this.assembly = assembly;
- }
-
- public IEnumerable<Type> all_types()
- {
- return assembly.GetTypes();
- }
- }
+using System;
+using System.Collections.Generic;
+
+namespace gorilla.infrastructure.reflection
+{
+ public class ApplicationAssembly : Assembly
+ {
+ readonly System.Reflection.Assembly assembly;
+
+ public ApplicationAssembly(System.Reflection.Assembly assembly)
+ {
+ this.assembly = assembly;
+ }
+
+ public IEnumerable<Type> all_types()
+ {
+ return assembly.GetTypes();
+ }
+ }
}
\ No newline at end of file
product/infrastructure/reflection/Assembly.cs
@@ -1,10 +1,10 @@
-using System;
-using System.Collections.Generic;
-
-namespace Gorilla.Commons.Infrastructure.Reflection
-{
- public interface Assembly
- {
- IEnumerable<Type> all_types();
- }
+using System;
+using System.Collections.Generic;
+
+namespace gorilla.infrastructure.reflection
+{
+ public interface Assembly
+ {
+ IEnumerable<Type> all_types();
+ }
}
\ No newline at end of file
product/infrastructure/reflection/EnvironmentExtensions.cs
@@ -1,12 +1,12 @@
-using System;
-
-namespace Gorilla.Commons.Infrastructure.Reflection
-{
- public static class EnvironmentExtensions
- {
- public static string startup_directory<T>(this T item)
- {
- return AppDomain.CurrentDomain.BaseDirectory;
- }
- }
+using System;
+
+namespace gorilla.infrastructure.reflection
+{
+ public static class EnvironmentExtensions
+ {
+ public static string startup_directory<T>(this T item)
+ {
+ return AppDomain.CurrentDomain.BaseDirectory;
+ }
+ }
}
\ No newline at end of file
product/infrastructure/registries/DefaultRegistry.cs
@@ -1,32 +1,32 @@
-using System.Collections;
-using System.Collections.Generic;
-using Gorilla.Commons.Infrastructure.Container;
-using gorilla.commons.utility;
-
-namespace Gorilla.Commons.Infrastructure.Registries
-{
- public class DefaultRegistry<T> : Registry<T>
- {
- readonly DependencyRegistry registry;
-
- public DefaultRegistry(DependencyRegistry registry)
- {
- this.registry = registry;
- }
-
- public IEnumerable<T> all()
- {
- return registry.get_all<T>();
- }
-
- public IEnumerator<T> GetEnumerator()
- {
- return all().GetEnumerator();
- }
-
- IEnumerator IEnumerable.GetEnumerator()
- {
- return GetEnumerator();
- }
- }
+using System.Collections;
+using System.Collections.Generic;
+using gorilla.infrastructure.container;
+using gorilla.utility;
+
+namespace gorilla.infrastructure.registries
+{
+ public class DefaultRegistry<T> : Registry<T>
+ {
+ readonly DependencyRegistry registry;
+
+ public DefaultRegistry(DependencyRegistry registry)
+ {
+ this.registry = registry;
+ }
+
+ public IEnumerable<T> all()
+ {
+ return registry.get_all<T>();
+ }
+
+ public IEnumerator<T> GetEnumerator()
+ {
+ return all().GetEnumerator();
+ }
+
+ IEnumerator IEnumerable.GetEnumerator()
+ {
+ return GetEnumerator();
+ }
+ }
}
\ No newline at end of file
product/infrastructure/infrastructure.csproj
@@ -8,8 +8,8 @@
<ProjectGuid>{AA5EEED9-4531-45F7-AFCD-AD9717D2E405}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
- <RootNamespace>gorilla.commons.infrastructure</RootNamespace>
- <AssemblyName>gorilla.commons.infrastructure</AssemblyName>
+ <RootNamespace>gorilla.infrastructure</RootNamespace>
+ <AssemblyName>gorilla.infrastructure</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<FileUpgradeFlags>
@@ -74,9 +74,6 @@
<Compile Include="container\DependencyResolutionException.cs" />
<Compile Include="container\DependencyRegistry.cs" />
<Compile Include="container\Resolve.cs" />
- <Compile Include="debugging\Launch.cs" />
- <Compile Include="filesystem\ApplicationFile.cs" />
- <Compile Include="filesystem\File.cs" />
<Compile Include="logging\TextLogger.cs" />
<Compile Include="logging\LogFactory.cs" />
<Compile Include="logging\Loggable.cs" />
product/testing/unit/infrastructure/cloning/BinarySerializerSpecs.cs
@@ -1,10 +1,9 @@
using System;
using System.IO;
-using Gorilla.Commons.Infrastructure.Cloning;
-using Gorilla.Commons.Testing;
+using gorilla.infrastructure.cloning;
using Machine.Specifications;
-namespace gorilla.commons.testing.unit.infrastructure.cloning
+namespace specs.unit.infrastructure.cloning
{
[Subject(typeof (BinarySerializer<TestItem>))]
public abstract class when_a_file_is_specified_to_serialize_an_item_to
product/testing/unit/infrastructure/container/ResolveSpecs.cs
@@ -1,10 +1,9 @@
using System;
-using Gorilla.Commons.Infrastructure.Container;
-using Gorilla.Commons.Testing;
-using gorilla.commons.utility;
+using gorilla.infrastructure.container;
+using gorilla.utility;
using Machine.Specifications;
-namespace gorilla.commons.testing.unit.infrastructure.container
+namespace specs.unit.infrastructure.container
{
[Subject(typeof (Resolve))]
public abstract class behaves_like_a_inversion_of_control_container
product/testing/unit/infrastructure/logging/LogSpecs.cs
@@ -1,9 +1,8 @@
-using Gorilla.Commons.Infrastructure.Container;
-using Gorilla.Commons.Infrastructure.Logging;
-using Gorilla.Commons.Testing;
+using gorilla.infrastructure.container;
+using gorilla.infrastructure.logging;
using Machine.Specifications;
-namespace gorilla.commons.testing.unIt.infrastructure.logging
+namespace specs.unit.infrastructure.logging
{
[Subject(typeof (Log))]
public class when_creating_a_logger_for_a_particular_type
product/testing/unit/infrastructure/proxies/ProxyFactorySpecs.cs
@@ -1,8 +1,7 @@
-using Gorilla.Commons.Infrastructure.Proxies;
-using Gorilla.Commons.Testing;
+using gorilla.infrastructure.proxies;
using Machine.Specifications;
-namespace gorilla.commons.testing.unit.infrastructure.proxies
+namespace specs.unit.infrastructure.proxies
{
public class ProxyFactorySpecs
{
product/testing/unit/infrastructure/registries/DefaultRegistrySpecs.cs
@@ -1,11 +1,10 @@
using System.Collections.Generic;
-using Gorilla.Commons.Infrastructure.Container;
-using Gorilla.Commons.Infrastructure.Registries;
-using Gorilla.Commons.Testing;
-using gorilla.commons.utility;
+using gorilla.infrastructure.container;
+using gorilla.infrastructure.registries;
+using gorilla.utility;
using Machine.Specifications;
-namespace gorilla.commons.testing.unit.infrastructure.registries
+namespace specs.unit.infrastructure.registries
{
[Subject(typeof (DefaultRegistry<int>))]
public class when_retrieving_all_the_items_from_the_default_repository
product/testing/unit/utility/ConfigurationExtensionsSpecs.cs
@@ -1,9 +1,8 @@
using System.Data;
-using Gorilla.Commons.Testing;
-using gorilla.commons.utility;
+using gorilla.utility;
using Machine.Specifications;
-namespace gorilla.commons.testing.unit.utility
+namespace specs.unit.utility
{
public class ConfigurationExtensionsSpecs
{
product/testing/unit/utility/DateSpecs.cs
@@ -1,8 +1,7 @@
-using Gorilla.Commons.Testing;
-using Gorilla.Commons.Utility;
+using gorilla.utility;
using Machine.Specifications;
-namespace gorilla.commons.testing.unit.utility
+namespace specs.unit.utility
{
public class DateSpecs
{
product/testing/unit/utility/EnumerableExtensionsSpecs.cs
@@ -1,9 +1,8 @@
using System.Collections.Generic;
-using Gorilla.Commons.Testing;
-using gorilla.commons.utility;
+using gorilla.utility;
using Machine.Specifications;
-namespace gorilla.commons.testing.unit.utility
+namespace specs.unit.utility
{
public class EnumerableExtensionsSpecs
{
product/testing/unit/utility/ListExtensionsSpecs.cs
@@ -1,9 +1,8 @@
using System.Collections.Generic;
-using Gorilla.Commons.Testing;
-using gorilla.commons.utility;
+using gorilla.utility;
using Machine.Specifications;
-namespace gorilla.commons.testing.unit.utility
+namespace specs.unit.utility
{
public class ListExtensionsSpecs
{
product/testing/unit/utility/MappingExtensionsSpecs.cs
@@ -1,8 +1,7 @@
-using Gorilla.Commons.Testing;
-using gorilla.commons.utility;
+using gorilla.utility;
using Machine.Specifications;
-namespace gorilla.commons.testing.unit.utility
+namespace specs.unit.utility
{
[Subject(typeof (MappingExtensions))]
public class when_transforming_type_A_to_type_B_then_C
product/testing/unit/utility/NotSpecificationSpecs.cs
@@ -1,8 +1,7 @@
-using Gorilla.Commons.Testing;
-using gorilla.commons.utility;
+using gorilla.utility;
using Machine.Specifications;
-namespace gorilla.commons.testing.unit.utility
+namespace specs.unit.utility
{
public class NotSpecificationSpecs
{
product/testing/unit/utility/NumericConversionsSpecs.cs
@@ -1,8 +1,7 @@
-using Gorilla.Commons.Testing;
-using gorilla.commons.utility;
+using gorilla.utility;
using Machine.Specifications;
-namespace gorilla.commons.testing.unit.utility
+namespace specs.unit.utility
{
[Subject(typeof (NumericConversions))]
public class when_converting_a_valid_string_to_a_long
product/testing/unit/utility/OrSpecificationSpecs.cs
@@ -1,8 +1,7 @@
-using Gorilla.Commons.Testing;
-using gorilla.commons.utility;
+using gorilla.utility;
using Machine.Specifications;
-namespace gorilla.commons.testing.unit.utility
+namespace specs.unit.utility
{
public class OrSpecificationSpecs
{
product/testing/unit/utility/PercentSpecs.cs
@@ -1,8 +1,7 @@
-using Gorilla.Commons.Testing;
-using Gorilla.Commons.Utility;
+using gorilla.utility;
using Machine.Specifications;
-namespace gorilla.commons.testing.unit.utility
+namespace specs.unit.utility
{
[Subject(typeof (Percent))]
public class when_comparing_fifty_divided_by_one_hundred_to_fifty_percent
product/testing/unit/utility/PredicateSpecificationSpecs.cs
@@ -1,8 +1,7 @@
-using Gorilla.Commons.Testing;
-using gorilla.commons.utility;
+using gorilla.utility;
using Machine.Specifications;
-namespace gorilla.commons.testing.unit.utility
+namespace specs.unit.utility
{
public class PredicateSpecificationSpecs
{
product/testing/unit/utility/SpecificationExtensionsSpecs.cs
@@ -1,8 +1,7 @@
-using Gorilla.Commons.Testing;
-using gorilla.commons.utility;
+using gorilla.utility;
using Machine.Specifications;
-namespace gorilla.commons.testing.unit.utility
+namespace specs.unit.utility
{
public class SpecificationExtensionsSpecs
{
product/testing/unit/utility/TypeExtensionsSpecs.cs
@@ -1,8 +1,7 @@
-using Gorilla.Commons.Testing;
-using gorilla.commons.utility;
+using gorilla.utility;
using Machine.Specifications;
-namespace gorilla.commons.testing.unit.utility
+namespace specs.unit.utility
{
public class TypeExtensionsSpecs
{
product/testing/unit/utility/VisitorExtensions.cs
@@ -1,7 +1,7 @@
using System.Collections.Generic;
-using gorilla.commons.utility;
+using gorilla.utility;
-namespace gorilla.commons.testing.unit.utility
+namespace specs.unit.utility
{
static public class VisitorExtensions
{
product/testing/assertions.cs
@@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using Machine.Specifications;
-namespace Gorilla.Commons.Testing
+namespace specs
{
static public class Assertions
{
product/testing/Call.cs
@@ -1,6 +1,6 @@
using System;
-namespace Gorilla.Commons.Testing
+namespace specs
{
static public class call
{
product/testing/Create.cs
@@ -4,7 +4,7 @@ using System.Linq;
using System.Reflection;
using Rhino.Mocks;
-namespace Gorilla.Commons.Testing
+namespace specs
{
static public class Create
{
product/testing/MockingExtensions.cs
@@ -4,7 +4,7 @@ using System.Linq;
using Rhino.Mocks;
using Rhino.Mocks.Interfaces;
-namespace Gorilla.Commons.Testing
+namespace specs
{
public static class MockingExtensions
{
product/testing/specs.csproj
@@ -8,7 +8,7 @@
<ProjectGuid>{44E65096-9657-4716-90F8-4535BABE8039}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
- <RootNamespace>gorilla.commons.testing</RootNamespace>
+ <RootNamespace>specs</RootNamespace>
<AssemblyName>specs</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
product/utility/AndSpecification.cs
@@ -1,19 +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);
- }
- }
+namespace gorilla.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/utility/AnonymousCommand.cs
@@ -1,22 +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();
- }
- }
+using System;
+using System.Linq.Expressions;
+
+namespace gorilla.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/utility/AnonymousDisposable.cs
@@ -1,19 +1,19 @@
-using System;
-
-namespace gorilla.commons.utility
-{
- public class AnonymousDisposable : IDisposable
- {
- readonly Action action;
-
- public AnonymousDisposable(Action action)
- {
- this.action = action;
- }
-
- public void Dispose()
- {
- action();
- }
- }
+using System;
+
+namespace gorilla.utility
+{
+ public class AnonymousDisposable : IDisposable
+ {
+ readonly Action action;
+
+ public AnonymousDisposable(Action action)
+ {
+ this.action = action;
+ }
+
+ public void Dispose()
+ {
+ action();
+ }
+ }
}
\ No newline at end of file
product/utility/AnonymousMapper.cs
@@ -1,19 +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);
- }
- }
+using System;
+
+namespace gorilla.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/utility/Builder.cs
@@ -1,4 +1,4 @@
-namespace gorilla.commons.utility
+namespace gorilla.utility
{
public interface Builder<out T>
{
product/utility/Callback.cs
@@ -1,4 +1,4 @@
-namespace gorilla.commons.utility
+namespace gorilla.utility
{
public interface Callback : Command
{
product/utility/CallbackCommand.cs
@@ -1,4 +1,4 @@
-namespace gorilla.commons.utility
+namespace gorilla.utility
{
public interface CallbackCommand<out T> : ParameterizedCommand<Callback<T>>
{
product/utility/ChainedCommand.cs
@@ -1,20 +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();
- }
- }
+namespace gorilla.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/utility/ChainedConfiguration.cs
@@ -1,20 +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);
- }
- }
+namespace gorilla.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/utility/ChainedMapper.cs
@@ -1,4 +1,4 @@
-namespace gorilla.commons.utility
+namespace gorilla.utility
{
public class ChainedMapper<Left, Middle, Right> : Mapper<Left, Right>
{
product/utility/Clock.cs
@@ -1,36 +1,36 @@
-using System;
-
-namespace Gorilla.Commons.Utility
-{
- public static class Clock
- {
- private static Func<DateTime> time_provider;
-
- static Clock()
- {
- reset();
- }
-
- public static Date today()
- {
- return time_provider();
- }
-
- public static DateTime now()
- {
- return time_provider();
- }
-
-#if DEBUG
- public static void change_time_provider_to(Func<DateTime> new_time_provider)
- {
- if (new_time_provider != null) time_provider = new_time_provider;
- }
-#endif
-
- public static void reset()
- {
- time_provider = () => DateTime.Now;
- }
- }
+using System;
+
+namespace gorilla.utility
+{
+ public static class Clock
+ {
+ private static Func<DateTime> time_provider;
+
+ static Clock()
+ {
+ reset();
+ }
+
+ public static Date today()
+ {
+ return time_provider();
+ }
+
+ public static DateTime now()
+ {
+ return time_provider();
+ }
+
+#if DEBUG
+ public static void change_time_provider_to(Func<DateTime> new_time_provider)
+ {
+ if (new_time_provider != null) time_provider = new_time_provider;
+ }
+#endif
+
+ public static void reset()
+ {
+ time_provider = () => DateTime.Now;
+ }
+ }
}
\ No newline at end of file
product/utility/Command.cs
@@ -1,7 +1,7 @@
-namespace gorilla.commons.utility
-{
- public interface Command
- {
- void run();
- }
+namespace gorilla.utility
+{
+ public interface Command
+ {
+ void run();
+ }
}
\ No newline at end of file
product/utility/CommandExtensions.cs
@@ -1,22 +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));
- }
- }
+using System;
+
+namespace gorilla.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/utility/ComponentFactory.cs
@@ -1,4 +1,4 @@
-namespace gorilla.commons.utility
-{
- public interface ComponentFactory<T> : Factory<T> where T : new() {}
+namespace gorilla.utility
+{
+ public interface ComponentFactory<T> : Factory<T> where T : new() {}
}
\ No newline at end of file
product/utility/Configuration.cs
@@ -1,4 +1,4 @@
-namespace gorilla.commons.utility
+namespace gorilla.utility
{
public interface Configuration<in T>
{
product/utility/ConfigurationExtensions.cs
@@ -1,16 +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;
- }
- }
+namespace gorilla.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/utility/ConversionExtensions.cs
@@ -1,37 +1,37 @@
-using System;
-using System.Collections;
-
-namespace gorilla.commons.utility
-{
- public static class ConversionExtensions
- {
- public static T downcast_to<T>(this object object_to_cast)
- {
- return (T) object_to_cast;
- }
-
- public static T converted_to<T>(this object item_to_convert)
- {
- if (item_to_convert.is_an_implementation_of<IConvertible>())
- {
- return (T) Convert.ChangeType(item_to_convert, typeof (T));
- }
- return item_to_convert.downcast_to<T>();
- }
-
- public static bool is_an_implementation_of<T>(this object item)
- {
- return item is T;
- }
-
- public static void call_on<T>(this object target, Action<T> action) where T : class
- {
- if (target as T != null) action(target as T);
- }
-
- public static void call_on_each<T>(this IEnumerable items, Action<T> action) where T : class
- {
- foreach (var item in items) item.call_on(action);
- }
- }
+using System;
+using System.Collections;
+
+namespace gorilla.utility
+{
+ public static class ConversionExtensions
+ {
+ public static T downcast_to<T>(this object object_to_cast)
+ {
+ return (T) object_to_cast;
+ }
+
+ public static T converted_to<T>(this object item_to_convert)
+ {
+ if (item_to_convert.is_an_implementation_of<IConvertible>())
+ {
+ return (T) Convert.ChangeType(item_to_convert, typeof (T));
+ }
+ return item_to_convert.downcast_to<T>();
+ }
+
+ public static bool is_an_implementation_of<T>(this object item)
+ {
+ return item is T;
+ }
+
+ public static void call_on<T>(this object target, Action<T> action) where T : class
+ {
+ if (target as T != null) action(target as T);
+ }
+
+ public static void call_on_each<T>(this IEnumerable items, Action<T> action) where T : class
+ {
+ foreach (var item in items) item.call_on(action);
+ }
+ }
}
\ No newline at end of file
product/utility/Date.cs
@@ -1,89 +1,88 @@
-using System;
-using System.Globalization;
-using gorilla.commons.utility;
-
-namespace Gorilla.Commons.Utility
-{
- [Serializable]
- public class Date : IComparable<Date>, IComparable, IEquatable<Date>
- {
- readonly long ticks;
-
- public Date(int year, int month, int day)
- {
- ticks = new DateTime(year, month, day).Ticks;
- }
-
- public bool is_in(Year the_year)
- {
- return the_year.represents(to_date_time());
- }
-
- public DateTime to_date_time()
- {
- return new DateTime(ticks);
- }
-
- static public implicit operator Date(DateTime date)
- {
- return new Date(date.Year, date.Month, date.Day);
- }
-
- static public implicit operator DateTime(Date date)
- {
- return date.to_date_time();
- }
-
- public int CompareTo(Date other)
- {
- var the_other_date = other.downcast_to<Date>();
- if (ticks.Equals(the_other_date.ticks))
- {
- return 0;
- }
- return ticks > the_other_date.ticks ? 1 : -1;
- }
-
- public bool Equals(Date other)
- {
- if (ReferenceEquals(null, other)) return false;
- if (ReferenceEquals(this, other)) return true;
- return other.ticks == ticks;
- }
-
- public override bool Equals(object obj)
- {
- if (ReferenceEquals(null, obj)) return false;
- if (ReferenceEquals(this, obj)) return true;
- if (obj.GetType() != typeof (Date)) return false;
- return Equals((Date) obj);
- }
-
- public override int GetHashCode()
- {
- return ticks.GetHashCode();
- }
-
- public static bool operator ==(Date left, Date right)
- {
- return Equals(left, right);
- }
-
- public static bool operator !=(Date left, Date right)
- {
- return !Equals(left, right);
- }
-
- public override string ToString()
- {
- return new DateTime(ticks, DateTimeKind.Local).ToString("MMM dd yyyy", CultureInfo.InvariantCulture);
- }
-
- int IComparable.CompareTo(object obj)
- {
- if (obj.is_an_implementation_of<Date>())
- return CompareTo(obj.downcast_to<Date>());
- throw new InvalidOperationException();
- }
- }
+using System;
+using System.Globalization;
+
+namespace gorilla.utility
+{
+ [Serializable]
+ public class Date : IComparable<Date>, IComparable, IEquatable<Date>
+ {
+ readonly long ticks;
+
+ public Date(int year, int month, int day)
+ {
+ ticks = new DateTime(year, month, day).Ticks;
+ }
+
+ public bool is_in(Year the_year)
+ {
+ return the_year.represents(to_date_time());
+ }
+
+ public DateTime to_date_time()
+ {
+ return new DateTime(ticks);
+ }
+
+ static public implicit operator Date(DateTime date)
+ {
+ return new Date(date.Year, date.Month, date.Day);
+ }
+
+ static public implicit operator DateTime(Date date)
+ {
+ return date.to_date_time();
+ }
+
+ public int CompareTo(Date other)
+ {
+ var the_other_date = other.downcast_to<Date>();
+ if (ticks.Equals(the_other_date.ticks))
+ {
+ return 0;
+ }
+ return ticks > the_other_date.ticks ? 1 : -1;
+ }
+
+ public bool Equals(Date other)
+ {
+ if (ReferenceEquals(null, other)) return false;
+ if (ReferenceEquals(this, other)) return true;
+ return other.ticks == ticks;
+ }
+
+ public override bool Equals(object obj)
+ {
+ if (ReferenceEquals(null, obj)) return false;
+ if (ReferenceEquals(this, obj)) return true;
+ if (obj.GetType() != typeof (Date)) return false;
+ return Equals((Date) obj);
+ }
+
+ public override int GetHashCode()
+ {
+ return ticks.GetHashCode();
+ }
+
+ public static bool operator ==(Date left, Date right)
+ {
+ return Equals(left, right);
+ }
+
+ public static bool operator !=(Date left, Date right)
+ {
+ return !Equals(left, right);
+ }
+
+ public override string ToString()
+ {
+ return new DateTime(ticks, DateTimeKind.Local).ToString("MMM dd yyyy", CultureInfo.InvariantCulture);
+ }
+
+ int IComparable.CompareTo(object obj)
+ {
+ if (obj.is_an_implementation_of<Date>())
+ return CompareTo(obj.downcast_to<Date>());
+ throw new InvalidOperationException();
+ }
+ }
}
\ No newline at end of file
product/utility/DefaultConstructorFactory.cs
@@ -1,10 +1,10 @@
-namespace gorilla.commons.utility
-{
- public class DefaultConstructorFactory<T> : ComponentFactory<T> where T : new()
- {
- public T create()
- {
- return new T();
- }
- }
+namespace gorilla.utility
+{
+ public class DefaultConstructorFactory<T> : ComponentFactory<T> where T : new()
+ {
+ public T create()
+ {
+ return new T();
+ }
+ }
}
\ No newline at end of file
product/utility/DisposableCommand.cs
@@ -1,7 +1,6 @@
-using System;
-using gorilla.commons.utility;
-
-namespace gorilla.commons.Utility
-{
- public interface DisposableCommand : Command, IDisposable {}
+using System;
+
+namespace gorilla.utility
+{
+ public interface DisposableCommand : Command, IDisposable {}
}
\ No newline at end of file
product/utility/EmptyCallback.cs
@@ -1,9 +1,9 @@
-namespace gorilla.commons.utility
-{
- public class EmptyCallback<T> : Callback<T>, Callback
- {
- public void run(T item) {}
-
- public void run() {}
- }
+namespace gorilla.utility
+{
+ public class EmptyCallback<T> : Callback<T>, Callback
+ {
+ public void run(T item) {}
+
+ public void run() {}
+ }
}
\ No newline at end of file
product/utility/EmptyCommand.cs
@@ -1,9 +1,9 @@
-namespace gorilla.commons.utility
-{
- public class EmptyCommand : Command
- {
- public void run()
- {
- }
- }
+namespace gorilla.utility
+{
+ public class EmptyCommand : Command
+ {
+ public void run()
+ {
+ }
+ }
}
\ No newline at end of file
product/utility/EnumerableExtensions.cs
@@ -1,46 +1,46 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-
-namespace gorilla.commons.utility
-{
- static public class EnumerableExtensions
- {
- static public IEnumerable<T> where<T>(this IEnumerable<T> items, Func<T, bool> condition_is_met)
- {
- return null == items ? Enumerable.Empty<T>() : items.Where(condition_is_met);
- }
-
- static public IList<T> databind<T>(this IEnumerable<T> items_to_bind_to)
- {
- return null == items_to_bind_to ? new List<T>() : items_to_bind_to.ToList();
- }
-
- static public IEnumerable<T> sorted_using<T>(this IEnumerable<T> items_to_sort, IComparer<T> sorting_algorithm)
- {
- var sorted_items = new List<T>(items_to_sort);
- sorted_items.Sort(sorting_algorithm);
- return sorted_items;
- }
-
- static public IEnumerable<T> all<T>(this IEnumerable<T> items)
- {
- foreach (var item in items ?? Enumerable.Empty<T>()) yield return item;
- }
-
- static public void each<T>(this IEnumerable<T> items, Action<T> action)
- {
- foreach (var item in items ?? Enumerable.Empty<T>()) action(item);
- }
-
- static public IEnumerable<T> join_with<T>(this IEnumerable<T> left, IEnumerable<T> right)
- {
- if (null == right) return left;
-
- var list = new List<T>();
- list.AddRange(left);
- list.AddRange(right);
- return list;
- }
- }
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace gorilla.utility
+{
+ static public class EnumerableExtensions
+ {
+ static public IEnumerable<T> where<T>(this IEnumerable<T> items, Func<T, bool> condition_is_met)
+ {
+ return null == items ? Enumerable.Empty<T>() : items.Where(condition_is_met);
+ }
+
+ static public IList<T> databind<T>(this IEnumerable<T> items_to_bind_to)
+ {
+ return null == items_to_bind_to ? new List<T>() : items_to_bind_to.ToList();
+ }
+
+ static public IEnumerable<T> sorted_using<T>(this IEnumerable<T> items_to_sort, IComparer<T> sorting_algorithm)
+ {
+ var sorted_items = new List<T>(items_to_sort);
+ sorted_items.Sort(sorting_algorithm);
+ return sorted_items;
+ }
+
+ static public IEnumerable<T> all<T>(this IEnumerable<T> items)
+ {
+ foreach (var item in items ?? Enumerable.Empty<T>()) yield return item;
+ }
+
+ static public void each<T>(this IEnumerable<T> items, Action<T> action)
+ {
+ foreach (var item in items ?? Enumerable.Empty<T>()) action(item);
+ }
+
+ static public IEnumerable<T> join_with<T>(this IEnumerable<T> left, IEnumerable<T> right)
+ {
+ if (null == right) return left;
+
+ var list = new List<T>();
+ list.AddRange(left);
+ list.AddRange(right);
+ return list;
+ }
+ }
}
\ No newline at end of file
product/utility/Factory.cs
@@ -1,4 +1,4 @@
-namespace gorilla.commons.utility
+namespace gorilla.utility
{
public interface Factory<out T>
{
product/utility/FactoryDelegate.cs
@@ -1,4 +1,4 @@
-namespace gorilla.commons.utility
+namespace gorilla.utility
{
public delegate Out FactoryDelegate<in In, out Out>(In input);
product/utility/FilteredVisitor.cs
@@ -1,19 +1,19 @@
-namespace gorilla.commons.utility
-{
- public class FilteredVisitor<T> : Visitor<T>
- {
- readonly Specification<T> condition;
- readonly Visitor<T> visitor;
-
- public FilteredVisitor(Specification<T> condition, Visitor<T> visitor)
- {
- this.condition = condition;
- this.visitor = visitor;
- }
-
- public void visit(T item_to_visit)
- {
- if (condition.is_satisfied_by(item_to_visit)) visitor.visit(item_to_visit);
- }
- }
+namespace gorilla.utility
+{
+ public class FilteredVisitor<T> : Visitor<T>
+ {
+ readonly Specification<T> condition;
+ readonly Visitor<T> visitor;
+
+ public FilteredVisitor(Specification<T> condition, Visitor<T> visitor)
+ {
+ this.condition = condition;
+ this.visitor = visitor;
+ }
+
+ public void visit(T item_to_visit)
+ {
+ if (condition.is_satisfied_by(item_to_visit)) visitor.visit(item_to_visit);
+ }
+ }
}
\ No newline at end of file
product/utility/FuncExtensions.cs
@@ -1,28 +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;
- };
- }
- }
+using System;
+
+namespace gorilla.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/utility/FuncSpecification.cs
@@ -1,19 +1,19 @@
-using System;
-
-namespace gorilla.commons.utility
-{
- public class FuncSpecification<T> : Specification<T>
- {
- Func<T, bool> condition;
-
- public FuncSpecification(Func<T, bool> condition)
- {
- this.condition = condition;
- }
-
- public bool is_satisfied_by(T item)
- {
- return condition(item);
- }
- }
+using System;
+
+namespace gorilla.utility
+{
+ public class FuncSpecification<T> : Specification<T>
+ {
+ Func<T, bool> condition;
+
+ public FuncSpecification(Func<T, bool> condition)
+ {
+ this.condition = condition;
+ }
+
+ public bool is_satisfied_by(T item)
+ {
+ return condition(item);
+ }
+ }
}
\ No newline at end of file
product/utility/Id.cs
@@ -1,6 +1,6 @@
using System;
-namespace gorilla.commons.utility
+namespace gorilla.utility
{
[Serializable]
public class Id<T>
product/utility/Identifiable.cs
@@ -1,7 +1,7 @@
-namespace gorilla.commons.utility
-{
- public interface Identifiable<T>
- {
- Id<T> id { get; }
- }
+namespace gorilla.utility
+{
+ public interface Identifiable<T>
+ {
+ Id<T> id { get; }
+ }
}
\ No newline at end of file
product/utility/Import.cs
@@ -1,4 +1,4 @@
-namespace gorilla.commons.utility
+namespace gorilla.utility
{
public interface Import<in T>
{
product/utility/ListExtensions.cs
@@ -1,42 +1,42 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-
-namespace gorilla.commons.utility
-{
- static public class ListExtensions
- {
- static public IListConstraint<T> add<T>(this ICollection<T> items, T item)
- {
- return new ListConstraint<T>(items, item);
- }
-
- static public IListConstraint<T> add_range<T>(this ICollection<T> items, IEnumerable<T> item)
- {
- return new ListConstraint<T>(items, item.ToArray());
- }
- }
-
- public class ListConstraint<T> : IListConstraint<T>
- {
- readonly ICollection<T> items;
- readonly T[] items_to_add;
-
- public ListConstraint(ICollection<T> list_to_constrain, params T[] items_to_add)
- {
- items = list_to_constrain;
- this.items_to_add = items_to_add;
- items_to_add.each(list_to_constrain.Add);
- }
-
- public void unless(Func<T, bool> predicate)
- {
- items_to_add.where(predicate).each(x => items.Remove(x));
- }
- }
-
- public interface IListConstraint<T>
- {
- void unless(Func<T, bool> predicate);
- }
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace gorilla.utility
+{
+ static public class ListExtensions
+ {
+ static public IListConstraint<T> add<T>(this ICollection<T> items, T item)
+ {
+ return new ListConstraint<T>(items, item);
+ }
+
+ static public IListConstraint<T> add_range<T>(this ICollection<T> items, IEnumerable<T> item)
+ {
+ return new ListConstraint<T>(items, item.ToArray());
+ }
+ }
+
+ public class ListConstraint<T> : IListConstraint<T>
+ {
+ readonly ICollection<T> items;
+ readonly T[] items_to_add;
+
+ public ListConstraint(ICollection<T> list_to_constrain, params T[] items_to_add)
+ {
+ items = list_to_constrain;
+ this.items_to_add = items_to_add;
+ items_to_add.each(list_to_constrain.Add);
+ }
+
+ public void unless(Func<T, bool> predicate)
+ {
+ items_to_add.where(predicate).each(x => items.Remove(x));
+ }
+ }
+
+ public interface IListConstraint<T>
+ {
+ void unless(Func<T, bool> predicate);
+ }
}
\ No newline at end of file
product/utility/Mapper.cs
@@ -1,4 +1,4 @@
-namespace gorilla.commons.utility
+namespace gorilla.utility
{
public interface Mapper<in Input, out Output>
{
product/utility/MappingExtensions.cs
@@ -1,37 +1,37 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-
-namespace gorilla.commons.utility
-{
- public static class MappingExtensions
- {
- public static Output map_using<Input, Output>(this Input item, Converter<Input, Output> conversion)
- {
- return conversion(item);
- }
-
- public static Output map_using<Input, Output>(this Input item, Mapper<Input, Output> mapper)
- {
- return map_using(item, x => mapper.map_from(x));
- }
-
- public static IEnumerable<Output> map_all_using<Input, Output>(this IEnumerable<Input> items,
- Converter<Input, Output> mapper)
- {
- return null == items ? new List<Output>() : items.Select(x => mapper(x));
- }
-
- public static IEnumerable<Output> map_all_using<Input, Output>(this IEnumerable<Input> items,
- Mapper<Input, Output> mapper)
- {
- return map_all_using(items, x => mapper.map_from(x));
- }
-
- 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);
- }
- }
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace gorilla.utility
+{
+ public static class MappingExtensions
+ {
+ public static Output map_using<Input, Output>(this Input item, Converter<Input, Output> conversion)
+ {
+ return conversion(item);
+ }
+
+ public static Output map_using<Input, Output>(this Input item, Mapper<Input, Output> mapper)
+ {
+ return map_using(item, x => mapper.map_from(x));
+ }
+
+ public static IEnumerable<Output> map_all_using<Input, Output>(this IEnumerable<Input> items,
+ Converter<Input, Output> mapper)
+ {
+ return null == items ? new List<Output>() : items.Select(x => mapper(x));
+ }
+
+ public static IEnumerable<Output> map_all_using<Input, Output>(this IEnumerable<Input> items,
+ Mapper<Input, Output> mapper)
+ {
+ return map_all_using(items, x => mapper.map_from(x));
+ }
+
+ 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);
+ }
+ }
}
\ No newline at end of file
product/utility/Notification.cs
@@ -1,7 +1,7 @@
-namespace gorilla.commons.utility
-{
- public interface Notification
- {
- void notify(params NotificationMessage[] messages);
- }
+namespace gorilla.utility
+{
+ public interface Notification
+ {
+ void notify(params NotificationMessage[] messages);
+ }
}
\ No newline at end of file
product/utility/NotificationMessage.cs
@@ -1,42 +1,42 @@
-namespace gorilla.commons.utility
-{
- public class NotificationMessage
- {
- public virtual string message { get; set; }
-
- static public implicit operator string(NotificationMessage message)
- {
- return message.ToString();
- }
-
- static public implicit operator NotificationMessage(string message)
- {
- return new NotificationMessage {message = message};
- }
-
- public override string ToString()
- {
- return message;
- }
-
- public bool Equals(NotificationMessage obj)
- {
- if (ReferenceEquals(null, obj)) return false;
- if (ReferenceEquals(this, obj)) return true;
- return Equals(obj.message, message);
- }
-
- public override bool Equals(object obj)
- {
- if (ReferenceEquals(null, obj)) return false;
- if (ReferenceEquals(this, obj)) return true;
- if (obj.GetType() != typeof (NotificationMessage)) return false;
- return Equals((NotificationMessage) obj);
- }
-
- public override int GetHashCode()
- {
- return (message != null ? message.GetHashCode() : 0);
- }
- }
+namespace gorilla.utility
+{
+ public class NotificationMessage
+ {
+ public virtual string message { get; set; }
+
+ static public implicit operator string(NotificationMessage message)
+ {
+ return message.ToString();
+ }
+
+ static public implicit operator NotificationMessage(string message)
+ {
+ return new NotificationMessage {message = message};
+ }
+
+ public override string ToString()
+ {
+ return message;
+ }
+
+ public bool Equals(NotificationMessage obj)
+ {
+ if (ReferenceEquals(null, obj)) return false;
+ if (ReferenceEquals(this, obj)) return true;
+ return Equals(obj.message, message);
+ }
+
+ public override bool Equals(object obj)
+ {
+ if (ReferenceEquals(null, obj)) return false;
+ if (ReferenceEquals(this, obj)) return true;
+ if (obj.GetType() != typeof (NotificationMessage)) return false;
+ return Equals((NotificationMessage) obj);
+ }
+
+ public override int GetHashCode()
+ {
+ return (message != null ? message.GetHashCode() : 0);
+ }
+ }
}
\ No newline at end of file
product/utility/NotSpecification.cs
@@ -1,17 +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);
- }
- }
+namespace gorilla.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/utility/NumericConversions.cs
@@ -1,22 +1,22 @@
-using System;
-
-namespace gorilla.commons.utility
-{
- public static class NumericConversions
- {
- public static int to_int<T>(this T item) where T : IConvertible
- {
- return Convert.ChangeType(item, typeof (int)).downcast_to<int>();
- }
-
- public static long to_long<T>(this T item) where T : IConvertible
- {
- return Convert.ChangeType(item, typeof (long)).downcast_to<long>();
- }
-
- public static double to_double<T>(this T item) where T : IConvertible
- {
- return Convert.ChangeType(item, typeof (double)).downcast_to<double>();
- }
- }
+using System;
+
+namespace gorilla.utility
+{
+ public static class NumericConversions
+ {
+ public static int to_int<T>(this T item) where T : IConvertible
+ {
+ return Convert.ChangeType(item, typeof (int)).downcast_to<int>();
+ }
+
+ public static long to_long<T>(this T item) where T : IConvertible
+ {
+ return Convert.ChangeType(item, typeof (long)).downcast_to<long>();
+ }
+
+ public static double to_double<T>(this T item) where T : IConvertible
+ {
+ return Convert.ChangeType(item, typeof (double)).downcast_to<double>();
+ }
+ }
}
\ No newline at end of file
product/utility/OrSpecification.cs
@@ -1,19 +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);
- }
- }
+namespace gorilla.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/utility/ParameterizedCommand.cs
@@ -1,4 +1,4 @@
-namespace gorilla.commons.utility
+namespace gorilla.utility
{
public interface ParameterizedCommand<in T>
{
product/utility/Parser.cs
@@ -1,4 +1,4 @@
-namespace gorilla.commons.utility
+namespace gorilla.utility
{
public interface Parser<out T>
{
product/utility/Percent.cs
@@ -1,62 +1,62 @@
-using System;
-using System.Globalization;
-
-namespace Gorilla.Commons.Utility
-{
- public class Percent
- {
- readonly double percentage;
-
- public Percent(double percentage)
- {
- this.percentage = percentage;
- }
-
- public Percent(double portion_of_total, double total)
- {
- percentage = portion_of_total/total;
- percentage *= 100;
- percentage = Math.Round(percentage, 1);
- }
-
- public bool represents(Percent other_percent)
- {
- return Equals(other_percent);
- }
-
- public bool is_less_than(Percent other_percent)
- {
- return percentage.CompareTo(other_percent.percentage) < 0;
- }
-
- public static implicit operator Percent(double percentage)
- {
- return new Percent(percentage);
- }
-
- public bool Equals(Percent other)
- {
- if (ReferenceEquals(null, other)) return false;
- if (ReferenceEquals(this, other)) return true;
- return other.percentage == percentage;
- }
-
- public override bool Equals(object obj)
- {
- if (ReferenceEquals(null, obj)) return false;
- if (ReferenceEquals(this, obj)) return true;
- if (obj.GetType() != typeof (Percent)) return false;
- return Equals((Percent) obj);
- }
-
- public override int GetHashCode()
- {
- return percentage.GetHashCode();
- }
-
- public override string ToString()
- {
- return percentage.ToString(CultureInfo.InvariantCulture);
- }
- }
+using System;
+using System.Globalization;
+
+namespace gorilla.utility
+{
+ public class Percent
+ {
+ readonly double percentage;
+
+ public Percent(double percentage)
+ {
+ this.percentage = percentage;
+ }
+
+ public Percent(double portion_of_total, double total)
+ {
+ percentage = portion_of_total/total;
+ percentage *= 100;
+ percentage = Math.Round(percentage, 1);
+ }
+
+ public bool represents(Percent other_percent)
+ {
+ return Equals(other_percent);
+ }
+
+ public bool is_less_than(Percent other_percent)
+ {
+ return percentage.CompareTo(other_percent.percentage) < 0;
+ }
+
+ public static implicit operator Percent(double percentage)
+ {
+ return new Percent(percentage);
+ }
+
+ public bool Equals(Percent other)
+ {
+ if (ReferenceEquals(null, other)) return false;
+ if (ReferenceEquals(this, other)) return true;
+ return other.percentage == percentage;
+ }
+
+ public override bool Equals(object obj)
+ {
+ if (ReferenceEquals(null, obj)) return false;
+ if (ReferenceEquals(this, obj)) return true;
+ if (obj.GetType() != typeof (Percent)) return false;
+ return Equals((Percent) obj);
+ }
+
+ public override int GetHashCode()
+ {
+ return percentage.GetHashCode();
+ }
+
+ public override string ToString()
+ {
+ return percentage.ToString(CultureInfo.InvariantCulture);
+ }
+ }
}
\ No newline at end of file
product/utility/PredicateSpecification.cs
@@ -1,19 +1,19 @@
-using System;
-
-namespace gorilla.commons.utility
-{
- public class PredicateSpecification<T> : Specification<T>
- {
- readonly Predicate<T> criteria;
-
- public PredicateSpecification(Predicate<T> criteria)
- {
- this.criteria = criteria;
- }
-
- public bool is_satisfied_by(T item)
- {
- return criteria(item);
- }
- }
+using System;
+
+namespace gorilla.utility
+{
+ public class PredicateSpecification<T> : Specification<T>
+ {
+ readonly Predicate<T> criteria;
+
+ public PredicateSpecification(Predicate<T> criteria)
+ {
+ this.criteria = criteria;
+ }
+
+ public bool is_satisfied_by(T item)
+ {
+ return criteria(item);
+ }
+ }
}
\ No newline at end of file
product/utility/Query.cs
@@ -1,4 +1,4 @@
-namespace gorilla.commons.utility
+namespace gorilla.utility
{
public interface Query<out TOutput>
{
product/utility/Registry.cs
@@ -1,6 +1,6 @@
using System.Collections.Generic;
-namespace gorilla.commons.utility
+namespace gorilla.utility
{
public interface Registry<out T> : IEnumerable<T>
{
product/utility/RegistryExtensions.cs
@@ -1,29 +1,29 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-
-namespace gorilla.commons.utility
-{
- public static class RegistryExtensions
- {
- public static K find_an_implementation_of<T, K>(this Registry<T> registry) where K : T
- {
- try
- {
- return registry
- .all()
- .Single(p => p.is_an_implementation_of<K>())
- .downcast_to<K>();
- }
- catch (Exception exception)
- {
- throw new Exception("Could Not Find an implementation of".formatted_using(typeof (K)), exception);
- }
- }
-
- public static IEnumerable<T> sort_all_using<T>(this Registry<T> registry, IComparer<T> comparer)
- {
- return registry.all().sorted_using(comparer);
- }
- }
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace gorilla.utility
+{
+ public static class RegistryExtensions
+ {
+ public static K find_an_implementation_of<T, K>(this Registry<T> registry) where K : T
+ {
+ try
+ {
+ return registry
+ .all()
+ .Single(p => p.is_an_implementation_of<K>())
+ .downcast_to<K>();
+ }
+ catch (Exception exception)
+ {
+ throw new Exception("Could Not Find an implementation of".formatted_using(typeof (K)), exception);
+ }
+ }
+
+ public static IEnumerable<T> sort_all_using<T>(this Registry<T> registry, IComparer<T> comparer)
+ {
+ return registry.all().sorted_using(comparer);
+ }
+ }
}
\ No newline at end of file
product/utility/Specification.cs
@@ -1,4 +1,4 @@
-namespace gorilla.commons.utility
+namespace gorilla.utility
{
public interface Specification<in T>
{
product/utility/SpecificationExtensions.cs
@@ -2,7 +2,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
-namespace gorilla.commons.utility
+namespace gorilla.utility
{
static public class SpecificationExtensions
{
product/utility/State.cs
@@ -1,6 +1,6 @@
-namespace gorilla.commons.utility
-{
- public interface State
- {
- }
+namespace gorilla.utility
+{
+ public interface State
+ {
+ }
}
\ No newline at end of file
product/utility/StringExtensions.cs
@@ -1,25 +1,25 @@
-namespace gorilla.commons.utility
-{
- static public class StringExtensions
- {
- static public string formatted_using(this string formatted_string, params object[] arguments)
- {
- return string.Format(formatted_string, arguments);
- }
-
- static public bool is_equal_to_ignoring_case(this string left, string right)
- {
- return string.Compare(left, right, true) == 0;
- }
-
- static public bool is_blank(this string message)
- {
- return string.IsNullOrEmpty(message);
- }
-
- static public string to_string<T>(this T item)
- {
- return "{0}".formatted_using(item);
- }
- }
+namespace gorilla.utility
+{
+ static public class StringExtensions
+ {
+ static public string formatted_using(this string formatted_string, params object[] arguments)
+ {
+ return string.Format(formatted_string, arguments);
+ }
+
+ static public bool is_equal_to_ignoring_case(this string left, string right)
+ {
+ return string.Compare(left, right, true) == 0;
+ }
+
+ static public bool is_blank(this string message)
+ {
+ return string.IsNullOrEmpty(message);
+ }
+
+ static public string to_string<T>(this T item)
+ {
+ return "{0}".formatted_using(item);
+ }
+ }
}
\ No newline at end of file
product/utility/SubjectOf.cs
@@ -1,4 +1,4 @@
-namespace gorilla.commons.utility
+namespace gorilla.utility
{
public interface SubjectOf<in State> where State : utility.State
{
product/utility/TypeExtensions.cs
@@ -1,40 +1,40 @@
-using System;
-using System.Linq;
-using System.Reflection;
-
-namespace gorilla.commons.utility
-{
- public static class TypeExtensions
- {
- public static Type last_interface(this Type type)
- {
- return type.GetInterfaces()[type.GetInterfaces().Length - 1];
- }
-
- public static Type first_interface(this Type type)
- {
- return type.GetInterfaces()[0];
- }
-
- public static bool is_a_generic_type(this Type type)
- {
- //return type.IsGenericType;
- return type.IsGenericTypeDefinition;
- }
-
- public static object default_value(this Type type)
- {
- return (type.IsValueType ? Activator.CreateInstance(type) : null);
- }
-
- public static Attribute get_attribute<Attribute>(this ICustomAttributeProvider provider)
- where Attribute : System.Attribute
- {
- return
- provider
- .GetCustomAttributes(typeof (Attribute), false)
- .Select(x => x.downcast_to<Attribute>())
- .First();
- }
- }
+using System;
+using System.Linq;
+using System.Reflection;
+
+namespace gorilla.utility
+{
+ public static class TypeExtensions
+ {
+ public static Type last_interface(this Type type)
+ {
+ return type.GetInterfaces()[type.GetInterfaces().Length - 1];
+ }
+
+ public static Type first_interface(this Type type)
+ {
+ return type.GetInterfaces()[0];
+ }
+
+ public static bool is_a_generic_type(this Type type)
+ {
+ //return type.IsGenericType;
+ return type.IsGenericTypeDefinition;
+ }
+
+ public static object default_value(this Type type)
+ {
+ return (type.IsValueType ? Activator.CreateInstance(type) : null);
+ }
+
+ public static Attribute get_attribute<Attribute>(this ICustomAttributeProvider provider)
+ where Attribute : System.Attribute
+ {
+ return
+ provider
+ .GetCustomAttributes(typeof (Attribute), false)
+ .Select(x => x.downcast_to<Attribute>())
+ .First();
+ }
+ }
}
\ No newline at end of file
product/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.utility</RootNamespace>
+ <AssemblyName>gorilla.utility</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<FileUpgradeFlags>
product/utility/ValueReturningVisitor.cs
@@ -1,4 +1,4 @@
-namespace gorilla.commons.utility
+namespace gorilla.utility
{
public interface ValueReturningVisitor<out Value, in T> : Visitor<T>
{
product/utility/Visitable.cs
@@ -1,4 +1,4 @@
-namespace gorilla.commons.utility
+namespace gorilla.utility
{
public interface Visitable<out T>
{
product/utility/Visitor.cs
@@ -1,4 +1,4 @@
-namespace gorilla.commons.utility
+namespace gorilla.utility
{
public interface Visitor<in T>
{
product/utility/Year.cs
@@ -1,53 +1,53 @@
-using System;
-
-namespace Gorilla.Commons.Utility
-{
- public class Year
- {
- readonly int the_underlying_year;
-
- public Year(int year) : this(new DateTime(year, 01, 01))
- {
- }
-
- public Year(DateTime date)
- {
- the_underlying_year = date.Year;
- }
-
- static public implicit operator Year(int year)
- {
- return new Year(year);
- }
-
- public bool Equals(Year obj)
- {
- if (ReferenceEquals(null, obj)) return false;
- if (ReferenceEquals(this, obj)) return true;
- return obj.the_underlying_year == the_underlying_year;
- }
-
- public override bool Equals(object obj)
- {
- if (ReferenceEquals(null, obj)) return false;
- if (ReferenceEquals(this, obj)) return true;
- if (obj.GetType() != typeof (Year)) return false;
- return Equals((Year) obj);
- }
-
- public override int GetHashCode()
- {
- return the_underlying_year;
- }
-
- public bool represents(DateTime time)
- {
- return time.Year.Equals(the_underlying_year);
- }
-
- public override string ToString()
- {
- return the_underlying_year.ToString();
- }
- }
+using System;
+
+namespace gorilla.utility
+{
+ public class Year
+ {
+ readonly int the_underlying_year;
+
+ public Year(int year) : this(new DateTime(year, 01, 01))
+ {
+ }
+
+ public Year(DateTime date)
+ {
+ the_underlying_year = date.Year;
+ }
+
+ static public implicit operator Year(int year)
+ {
+ return new Year(year);
+ }
+
+ public bool Equals(Year obj)
+ {
+ if (ReferenceEquals(null, obj)) return false;
+ if (ReferenceEquals(this, obj)) return true;
+ return obj.the_underlying_year == the_underlying_year;
+ }
+
+ public override bool Equals(object obj)
+ {
+ if (ReferenceEquals(null, obj)) return false;
+ if (ReferenceEquals(this, obj)) return true;
+ if (obj.GetType() != typeof (Year)) return false;
+ return Equals((Year) obj);
+ }
+
+ public override int GetHashCode()
+ {
+ return the_underlying_year;
+ }
+
+ public bool represents(DateTime time)
+ {
+ return time.Year.Equals(the_underlying_year);
+ }
+
+ public override string ToString()
+ {
+ return the_underlying_year.ToString();
+ }
+ }
}
\ No newline at end of file