Commit 216ecf3
Changed files (122)
product
desktop.ui
infrastructure
debugging
filesystem
Properties
proxies
registries
threading
utility
Properties
support
product/desktop.ui/Properties/AssemblyInfo.cs
@@ -1,4 +1,4 @@
-using System.Reflection;
+using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
@@ -12,7 +12,7 @@ using System.Windows;
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("desktop.ui")]
-[assembly: AssemblyCopyright("Copyright © 2011")]
+[assembly: AssemblyCopyright("Copyright � 2011")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
@@ -51,5 +51,5 @@ using System.Windows;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
+[assembly: AssemblyVersion("2011.3.17.1312")]
+[assembly: AssemblyFileVersion("2011.3.17.1312")]
product/desktop.ui/Properties/AssemblyInfo.cs.template
@@ -0,0 +1,55 @@
+using System.Reflection;
+using System.Resources;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Windows;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("desktop.ui")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("desktop.ui")]
+[assembly: AssemblyCopyright("Copyright © 2011")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+//In order to begin building localizable applications, set
+//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
+//inside a <PropertyGroup>. For example, if you are using US english
+//in your source files, set the <UICulture> to en-US. Then uncomment
+//the NeutralResourceLanguage attribute below. Update the "en-US" in
+//the line below to match the UICulture setting in the project file.
+
+//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
+
+
+[assembly: ThemeInfo(
+ ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
+ //(used if a resource is not found in the page,
+ // or application resource dictionaries)
+ ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
+ //(used if a resource is not found in the page,
+ // app, or any theme specific resource dictionaries)
+)]
+
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("${version.number}")]
+[assembly: AssemblyFileVersion("${version.number}")]
product/desktop.ui/desktop.ui.csproj
@@ -35,6 +35,9 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
+ <PropertyGroup>
+ <NoWin32Manifest>true</NoWin32Manifest>
+ </PropertyGroup>
<ItemGroup>
<Reference Include="Autofac">
<HintPath>..\..\thirdparty\autofac\Autofac.dll</HintPath>
product/infrastructure/cloning/BinarySerializer.cs
@@ -1,11 +0,0 @@
-using System.Runtime.Serialization.Formatters.Binary;
-
-namespace 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 +0,0 @@
-using System.IO;
-using System.Runtime.Serialization;
-
-namespace 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 +0,0 @@
-using System.IO;
-
-namespace 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 +0,0 @@
-using System;
-
-namespace 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 +0,0 @@
-using System.Collections.Generic;
-
-namespace 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 +0,0 @@
-using System;
-using utility;
-
-namespace infrastructure.container
-{
- public class DependencyResolutionException<T> : Exception
- {
- public DependencyResolutionException(Exception inner_exception)
- : base("Could not resolve {0}".format(typeof (T).FullName), inner_exception)
- {
- }
- }
-}
\ No newline at end of file
product/infrastructure/container/Resolve.cs
@@ -1,31 +0,0 @@
-using System;
-
-namespace infrastructure.container
-{
- static public class Resolve
- {
- static DependencyRegistry underlying_registry;
-
- static public void initialize_with(DependencyRegistry registry)
- {
- underlying_registry = registry;
- }
-
- 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 underlying_registry != null;
- }
- }
-}
\ No newline at end of file
product/infrastructure/debugging/Launch.cs
@@ -1,15 +0,0 @@
-using System.Diagnostics;
-
-namespace 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 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 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 +0,0 @@
-using System;
-using infrastructure.container;
-
-namespace 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 +0,0 @@
-using System;
-
-namespace 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 +0,0 @@
-namespace infrastructure.logging
-{
- public interface Loggable
- {
-
- }
-}
\ No newline at end of file
product/infrastructure/logging/Logger.cs
@@ -1,11 +0,0 @@
-using System;
-
-namespace 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 +0,0 @@
-using System;
-
-namespace 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 +0,0 @@
-using System;
-using System.IO;
-using System.Threading;
-using utility;
-
-namespace 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.format(arguments));
- }
-
- public void error(Exception e)
- {
- writer.WriteLine("{0}", e);
- }
- }
-}
\ No newline at end of file
product/infrastructure/Properties/AssemblyInfo.cs
@@ -1,36 +0,0 @@
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-[assembly: AssemblyTitle("infrastructure")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("infrastructure")]
-[assembly: AssemblyCopyright("Copyright © 2011")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// Setting ComVisible to false makes the types in this assembly not visible
-// to COM components. If you need to access a type in this assembly from
-// COM, set the ComVisible attribute to true on that type.
-[assembly: ComVisible(false)]
-
-// The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("c400224d-0e9e-4936-aabb-c4711ec81f1a")]
-
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Build and Revision Numbers
-// by using the '*' as shown below:
-// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
product/infrastructure/proxies/ExceptionExtensions.cs
@@ -1,18 +0,0 @@
-using System;
-using System.Reflection;
-
-namespace 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 +0,0 @@
-namespace infrastructure.proxies
-{
- public interface Interceptor
- {
- void intercept(Invocation invocation);
- }
-}
\ No newline at end of file
product/infrastructure/proxies/Invocation.cs
@@ -1,12 +0,0 @@
-using System.Reflection;
-
-namespace 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 +0,0 @@
-using System.Collections.Generic;
-using System.Reflection;
-using System.Runtime.Remoting.Messaging;
-using utility;
-
-namespace 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 +0,0 @@
-namespace 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 +0,0 @@
-using System.Collections.Generic;
-using System.Runtime.Remoting.Messaging;
-using System.Runtime.Remoting.Proxies;
-using utility;
-
-namespace 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,35 +0,0 @@
-using System;
-using System.Collections.Generic;
-using utility;
-
-namespace infrastructure.reflection
-{
- public class ApplicationAssembly : Assembly
- {
- IList<Type> types = new List<Type>();
-
- public ApplicationAssembly(params System.Reflection.Assembly[] assemblies)
- {
- assemblies.each(x => types.add_range(x.GetTypes()));
- }
-
- public IEnumerable<Type> all_types()
- {
- return types;
- }
-
- public IEnumerable<Type> all_types(Specification<Type> matching)
- {
- return all_types().where(x => matching.is_satisfied_by(x));
- }
-
- public IEnumerable<Type> all_classes_that_implement<Contract>()
- {
- return all_types()
- .where(x => typeof (Contract).IsAssignableFrom(x))
- .where(x => !x.IsInterface)
- .where(x => !x.IsAbstract)
- .where(x => !x.IsGenericType);
- }
- }
-}
\ No newline at end of file
product/infrastructure/reflection/Assembly.cs
@@ -1,13 +0,0 @@
-using System;
-using System.Collections.Generic;
-using utility;
-
-namespace infrastructure.reflection
-{
- public interface Assembly
- {
- IEnumerable<Type> all_types();
- IEnumerable<Type> all_types(Specification<Type> matching);
- IEnumerable<Type> all_classes_that_implement<T>();
- }
-}
\ No newline at end of file
product/infrastructure/reflection/EnvironmentExtensions.cs
@@ -1,12 +0,0 @@
-using System;
-
-namespace 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 +0,0 @@
-using System.Collections;
-using System.Collections.Generic;
-using infrastructure.container;
-using utility;
-
-namespace 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/threading/AsynchronousCommandProcessor.cs
@@ -1,113 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Threading;
-using infrastructure.logging;
-using utility;
-
-namespace infrastructure.threading
-{
- public class AsynchronousCommandProcessor : CommandProcessor
- {
- readonly Queue<Command> queued_commands;
- readonly EventWaitHandle manual_reset;
- readonly IList<Thread> worker_threads;
- bool keep_working;
-
- static public readonly Command Empty = new EmptyCommand();
-
- public AsynchronousCommandProcessor()
- {
- queued_commands = new Queue<Command>();
- worker_threads = new List<Thread>();
- manual_reset = new ManualResetEvent(false);
- }
-
- public void add(Action command)
- {
- add(new AnonymousCommand(command));
- }
-
- public void add(Command command_to_process)
- {
- lock (queued_commands)
- {
- if (queued_commands.Contains(command_to_process)) return;
- queued_commands.Enqueue(command_to_process);
- reset_thread();
- }
- }
-
- public void run()
- {
- reset_thread();
- keep_working = true;
- var worker_thread = new Thread(run_commands);
- worker_thread.SetApartmentState(ApartmentState.STA);
- worker_threads.Add(worker_thread);
- worker_thread.Start();
- }
-
- public void stop()
- {
- keep_working = false;
- manual_reset.Set();
- //manual_reset.Close();
- }
-
- [STAThread]
- void run_commands()
- {
- while (keep_working)
- {
- manual_reset.WaitOne();
- run_next_command();
- }
- }
-
- void run_next_command()
- {
- var command = Empty;
- within_lock(() =>
- {
- if (queued_commands.Count == 0)
- manual_reset.Reset();
- else
- command = queued_commands.Dequeue();
- });
- safely_invoke(() =>
- {
- command.run();
- });
- reset_thread();
- }
-
- void safely_invoke(Action action)
- {
- try
- {
- action();
- }
- catch (Exception e)
- {
- this.log().error(e);
- }
- }
-
- void reset_thread()
- {
- within_lock(() =>
- {
- if (queued_commands.Count > 0) manual_reset.Set();
- else manual_reset.Reset();
- });
- }
-
- void within_lock(Action action)
- {
- lock (queued_commands)
- {
- action();
- }
- }
- }
-}
\ No newline at end of file
product/infrastructure/threading/BackgroundThread.cs
@@ -1,30 +0,0 @@
-using utility;
-
-namespace infrastructure.threading
-{
- public interface IBackgroundThread : DisposableCommand {}
-
- public class BackgroundThread : IBackgroundThread
- {
- readonly IWorkerThread worker_thread;
-
- public BackgroundThread(DisposableCommand command_to_execute) : this(command_to_execute, new WorkerThread()) {}
-
- public BackgroundThread(DisposableCommand command_to_execute, IWorkerThread worker_thread)
- {
- this.worker_thread = worker_thread;
- worker_thread.DoWork += (sender, e) => command_to_execute.run();
- worker_thread.Disposed += (sender, e) => command_to_execute.Dispose();
- }
-
- public void run()
- {
- worker_thread.begin();
- }
-
- public void Dispose()
- {
- worker_thread.Dispose();
- }
- }
-}
\ No newline at end of file
product/infrastructure/threading/BackgroundThreadFactory.cs
@@ -1,49 +0,0 @@
-using System;
-using infrastructure.container;
-using utility;
-
-namespace infrastructure.threading
-{
- public interface IBackgroundThreadFactory
- {
- IBackgroundThread create_for<CommandToExecute>() where CommandToExecute : DisposableCommand;
- IBackgroundThread create_for(Action action);
- }
-
- public class BackgroundThreadFactory : IBackgroundThreadFactory
- {
- readonly DependencyRegistry registry;
-
- public BackgroundThreadFactory(DependencyRegistry registry)
- {
- this.registry = registry;
- }
-
- public IBackgroundThread create_for<CommandToExecute>() where CommandToExecute : DisposableCommand
- {
- return new BackgroundThread(registry.get_a<CommandToExecute>());
- }
-
- public IBackgroundThread create_for(Action action)
- {
- return new BackgroundThread(new AnonymousDisposableCommand(action));
- }
-
- class AnonymousDisposableCommand : DisposableCommand
- {
- readonly Action action;
-
- public AnonymousDisposableCommand(Action action)
- {
- this.action = action;
- }
-
- public void run()
- {
- action();
- }
-
- public void Dispose() {}
- }
- }
-}
\ No newline at end of file
product/infrastructure/threading/CommandProcessor.cs
@@ -1,12 +0,0 @@
-using System;
-using utility;
-
-namespace infrastructure.threading
-{
- public interface CommandProcessor : Command
- {
- void add(Action command);
- void add(Command command_to_process);
- void stop();
- }
-}
\ No newline at end of file
product/infrastructure/threading/CurrentThread.cs
@@ -1,19 +0,0 @@
-using System.Threading;
-
-namespace infrastructure.threading
-{
- public class CurrentThread : IThread
- {
- public T provide_slot_for<T>() where T : class, new()
- {
- var slot = Thread.GetNamedDataSlot(create_key_for<T>());
- if (null == Thread.GetData(slot)) Thread.SetData(slot, new T());
- return (T) Thread.GetData(slot);
- }
-
- string create_key_for<T>()
- {
- return Thread.CurrentThread.ManagedThreadId + GetType().FullName + typeof (T).FullName;
- }
- }
-}
\ No newline at end of file
product/infrastructure/threading/IntervalTimer.cs
@@ -1,48 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Timers;
-
-namespace infrastructure.threading
-{
- public interface ITimer
- {
- void start_notifying(ITimerClient client_to_be_notified, TimeSpan span);
- void stop_notifying(ITimerClient client_to_stop_notifying);
- }
-
- public class IntervalTimer : ITimer
- {
- readonly ITimerFactory factory;
- readonly IDictionary<ITimerClient, Timer> timers;
-
- public IntervalTimer() : this(new TimerFactory())
- {
- }
-
- public IntervalTimer(ITimerFactory factory)
- {
- this.factory = factory;
- timers = new Dictionary<ITimerClient, Timer>();
- }
-
- public void start_notifying(ITimerClient client_to_be_notified, TimeSpan span)
- {
- stop_notifying(client_to_be_notified);
-
- var timer = factory.create_for(span);
- timer.Elapsed += (sender, args) =>
- {
- client_to_be_notified.notify();
- };
- timer.Start();
- timers[client_to_be_notified] = timer;
- }
-
- public void stop_notifying(ITimerClient client_to_stop_notifying)
- {
- if (!timers.ContainsKey(client_to_stop_notifying)) return;
- timers[client_to_stop_notifying].Stop();
- timers[client_to_stop_notifying].Dispose();
- }
- }
-}
\ No newline at end of file
product/infrastructure/threading/IThread.cs
@@ -1,7 +0,0 @@
-namespace infrastructure.threading
-{
- public interface IThread
- {
- T provide_slot_for<T>() where T : class, new();
- }
-}
\ No newline at end of file
product/infrastructure/threading/ITimerClient.cs
@@ -1,7 +0,0 @@
-namespace infrastructure.threading
-{
- public interface ITimerClient
- {
- void notify();
- }
-}
\ No newline at end of file
product/infrastructure/threading/IWorkerThread.cs
@@ -1,12 +0,0 @@
-using System;
-using System.ComponentModel;
-
-namespace infrastructure.threading
-{
- public interface IWorkerThread : IDisposable
- {
- event DoWorkEventHandler DoWork;
- event EventHandler Disposed;
- void begin();
- }
-}
\ No newline at end of file
product/infrastructure/threading/PerThread.cs
@@ -1,59 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Threading;
-using utility;
-
-namespace infrastructure.threading
-{
- public class PerThread : IContext
- {
- readonly IDictionary<int, LocalDataStoreSlot> slots;
- readonly object mutex = new object();
-
- public PerThread()
- {
- slots = new Dictionary<int, LocalDataStoreSlot>();
- }
-
- public bool contains<T>(Key<T> key)
- {
- return key.is_found_in(get_items());
- }
-
- public void add<T>(Key<T> key, T value)
- {
- key.add_value_to(get_items(), value);
- }
-
- public T value_for<T>(Key<T> key)
- {
- return key.parse_from(get_items());
- }
-
- public void remove<T>(Key<T> key)
- {
- key.remove_from(get_items());
- }
-
- IDictionary get_items()
- {
- var id = Thread.CurrentThread.ManagedThreadId;
- within_lock(() =>
- {
- if (!slots.ContainsKey(id))
- {
- var slot = Thread.GetNamedDataSlot(GetType().FullName);
- slots.Add(id, slot);
- Thread.SetData(slot, new Hashtable());
- }
- });
- return (IDictionary) Thread.GetData(slots[id]);
- }
-
- void within_lock(Action action)
- {
- lock (mutex) action();
- }
- }
-}
\ No newline at end of file
product/infrastructure/threading/PerThreadScopedStorage.cs
@@ -1,20 +0,0 @@
-using System.Collections;
-using utility;
-
-namespace infrastructure.threading
-{
- public class PerThreadScopedStorage : IScopedStorage
- {
- readonly IThread current_thread;
-
- public PerThreadScopedStorage(IThread current_thread)
- {
- this.current_thread = current_thread;
- }
-
- public IDictionary provide_storage()
- {
- return current_thread.provide_slot_for<Hashtable>();
- }
- }
-}
\ No newline at end of file
product/infrastructure/threading/SynchronizationContextFactory.cs
@@ -1,23 +0,0 @@
-using System.Threading;
-using infrastructure.container;
-using utility;
-
-namespace infrastructure.threading
-{
- public interface ISynchronizationContextFactory : Factory<ISynchronizationContext> {}
-
- public class SynchronizationContextFactory : ISynchronizationContextFactory
- {
- readonly DependencyRegistry registry;
-
- public SynchronizationContextFactory(DependencyRegistry registry)
- {
- this.registry = registry;
- }
-
- public ISynchronizationContext create()
- {
- return new SynchronizedContext(registry.get_a<SynchronizationContext>());
- }
- }
-}
\ No newline at end of file
product/infrastructure/threading/SynchronizedCommand.cs
@@ -1,28 +0,0 @@
-using System;
-using System.Threading;
-using utility;
-
-namespace infrastructure.threading
-{
- public interface ISynchronizedCommand : Command<Action>, Command<Command> {}
-
- public class SynchronizedCommand : ISynchronizedCommand
- {
- readonly SynchronizationContext context;
-
- public SynchronizedCommand(SynchronizationContext context)
- {
- this.context = context;
- }
-
- public void run_against(Action item)
- {
- context.Post(x => item(), new object());
- }
-
- public void run_against(Command item)
- {
- run_against(item.run);
- }
- }
-}
\ No newline at end of file
product/infrastructure/threading/SynchronizedContext.cs
@@ -1,23 +0,0 @@
-using System.Threading;
-using utility;
-
-namespace infrastructure.threading
-{
- public interface ISynchronizationContext : Command<Command> {}
-
- public class SynchronizedContext : ISynchronizationContext
- {
- readonly SynchronizationContext context;
-
- public SynchronizedContext(SynchronizationContext context)
- {
- this.context = context;
- }
-
- public void run_against(Command item)
- {
- context.Post(x => item.run(), new object());
- //context.Send(x => item.run(), new object());
- }
- }
-}
\ No newline at end of file
product/infrastructure/threading/SynchronousCommandProcessor.cs
@@ -1,36 +0,0 @@
-using System;
-using System.Collections.Generic;
-using utility;
-
-namespace infrastructure.threading
-{
- public class SynchronousCommandProcessor : CommandProcessor
- {
- readonly Queue<Command> queued_commands;
-
- public SynchronousCommandProcessor()
- {
- queued_commands = new Queue<Command>();
- }
-
- public void add(Action command)
- {
- add(new AnonymousCommand(command));
- }
-
- public void add(Command command_to_process)
- {
- queued_commands.Enqueue(command_to_process);
- }
-
- public void run()
- {
- while (queued_commands.Count > 0) queued_commands.Dequeue().run();
- }
-
- public void stop()
- {
- queued_commands.Clear();
- }
- }
-}
\ No newline at end of file
product/infrastructure/threading/ThreadingExtensions.cs
@@ -1,12 +0,0 @@
-using utility;
-
-namespace infrastructure.threading
-{
- static public class ThreadingExtensions
- {
- static public IBackgroundThread on_a_background_thread(this DisposableCommand command)
- {
- return new BackgroundThread(command);
- }
- }
-}
\ No newline at end of file
product/infrastructure/threading/TimerFactory.cs
@@ -1,22 +0,0 @@
-using System;
-using System.Timers;
-
-namespace infrastructure.threading
-{
- public interface ITimerFactory
- {
- Timer create_for(TimeSpan span);
- }
-
- public class TimerFactory : ITimerFactory
- {
- public Timer create_for(TimeSpan span)
- {
- if (span.Seconds > 0) {
- var milliseconds = span.Seconds*1000;
- return new Timer(milliseconds);
- }
- return new Timer(span.Ticks);
- }
- }
-}
\ No newline at end of file
product/infrastructure/threading/WorkerThread.cs
@@ -1,50 +0,0 @@
-using System;
-using System.ComponentModel;
-using infrastructure.logging;
-
-namespace infrastructure.threading
-{
- public class WorkerThread : Component, IWorkerThread
- {
- static readonly object do_work_key = new object();
- bool is_running;
- readonly Action background_thread;
-
- public WorkerThread()
- {
- background_thread = worker_thread_start;
- }
-
- public event DoWorkEventHandler DoWork
- {
- add { Events.AddHandler(do_work_key, value); }
- remove { Events.RemoveHandler(do_work_key, value); }
- }
-
- public void begin()
- {
- if (is_running)
- {
- throw new InvalidOperationException("Worker Thread Is Already Running");
- }
- is_running = true;
- background_thread.BeginInvoke(null, null);
- }
-
- void worker_thread_start()
- {
- try
- {
- var handler = (DoWorkEventHandler) Events[do_work_key];
- if (handler != null)
- {
- handler(this, new DoWorkEventArgs(null));
- }
- }
- catch (Exception e)
- {
- this.log().error(e);
- }
- }
- }
-}
\ No newline at end of file
product/infrastructure/infrastructure.csproj
@@ -1,99 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProductVersion>8.0.30703</ProductVersion>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{CC006EB6-4E3C-4497-B8CC-5CAF54E40113}</ProjectGuid>
- <OutputType>Library</OutputType>
- <AppDesignerFolder>Properties</AppDesignerFolder>
- <RootNamespace>infrastructure</RootNamespace>
- <AssemblyName>infrastructure</AssemblyName>
- <TargetFrameworkVersion>v4.0</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="System" />
- <Reference Include="System.Core" />
- <Reference Include="System.Xml.Linq" />
- <Reference Include="System.Data.DataSetExtensions" />
- <Reference Include="Microsoft.CSharp" />
- <Reference Include="System.Data" />
- <Reference Include="System.Xml" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="cloning\BinarySerializer.cs" />
- <Compile Include="cloning\FileStreamSerializer.cs" />
- <Compile Include="cloning\Prototype.cs" />
- <Compile Include="cloning\Serializer.cs" />
- <Compile Include="container\DependencyRegistry.cs" />
- <Compile Include="container\DependencyResolutionException.cs" />
- <Compile Include="container\Resolve.cs" />
- <Compile Include="debugging\Launch.cs" />
- <Compile Include="filesystem\ApplicationFile.cs" />
- <Compile Include="filesystem\File.cs" />
- <Compile Include="logging\Log.cs" />
- <Compile Include="logging\LogFactory.cs" />
- <Compile Include="logging\Loggable.cs" />
- <Compile Include="logging\Logger.cs" />
- <Compile Include="logging\LoggingExtensions.cs" />
- <Compile Include="logging\TextLogger.cs" />
- <Compile Include="Properties\AssemblyInfo.cs" />
- <Compile Include="proxies\ExceptionExtensions.cs" />
- <Compile Include="proxies\Interceptor.cs" />
- <Compile Include="proxies\Invocation.cs" />
- <Compile Include="proxies\MethodCallInvocation.cs" />
- <Compile Include="proxies\ProxyFactory.cs" />
- <Compile Include="proxies\RemotingProxyFactory.cs" />
- <Compile Include="reflection\ApplicationAssembly.cs" />
- <Compile Include="reflection\Assembly.cs" />
- <Compile Include="reflection\EnvironmentExtensions.cs" />
- <Compile Include="registries\DefaultRegistry.cs" />
- <Compile Include="threading\AsynchronousCommandProcessor.cs" />
- <Compile Include="threading\BackgroundThread.cs" />
- <Compile Include="threading\BackgroundThreadFactory.cs" />
- <Compile Include="threading\CommandProcessor.cs" />
- <Compile Include="threading\CurrentThread.cs" />
- <Compile Include="threading\IntervalTimer.cs" />
- <Compile Include="threading\IThread.cs" />
- <Compile Include="threading\ITimerClient.cs" />
- <Compile Include="threading\IWorkerThread.cs" />
- <Compile Include="threading\PerThread.cs" />
- <Compile Include="threading\PerThreadScopedStorage.cs" />
- <Compile Include="threading\SynchronizationContextFactory.cs" />
- <Compile Include="threading\SynchronizedCommand.cs" />
- <Compile Include="threading\SynchronizedContext.cs" />
- <Compile Include="threading\SynchronousCommandProcessor.cs" />
- <Compile Include="threading\ThreadingExtensions.cs" />
- <Compile Include="threading\TimerFactory.cs" />
- <Compile Include="threading\WorkerThread.cs">
- <SubType>Component</SubType>
- </Compile>
- </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/utility/Properties/AssemblyInfo.cs
@@ -1,36 +0,0 @@
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-[assembly: AssemblyTitle("utility")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("utility")]
-[assembly: AssemblyCopyright("Copyright © 2011")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// Setting ComVisible to false makes the types in this assembly not visible
-// to COM components. If you need to access a type in this assembly from
-// COM, set the ComVisible attribute to true on that type.
-[assembly: ComVisible(false)]
-
-// The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("fcb24300-de08-47a5-a4b0-efb606c1a008")]
-
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Build and Revision Numbers
-// by using the '*' as shown below:
-// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
product/utility/AndSpecification.cs
@@ -1,19 +0,0 @@
-namespace 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 +0,0 @@
-using System;
-using System.Linq.Expressions;
-
-namespace 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 +0,0 @@
-using System;
-
-namespace 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 +0,0 @@
-using System;
-
-namespace 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/AttributeExtensions.cs
@@ -1,28 +0,0 @@
-using System;
-using System.Reflection;
-
-namespace utility
-{
- static public class AttributeExtensions
- {
- static public bool is_decorated_with<T>(this object item) where T : Attribute
- {
- return item.GetType().is_decorated_with<T>();
- }
-
- static public bool is_decorated_with<T>(this ICustomAttributeProvider item) where T : Attribute
- {
- return item.IsDefined(typeof (T), true);
- }
-
- static public T attribute<T>(this object item) where T : Attribute
- {
- return item.GetType().attribute<T>();
- }
-
- static public T attribute<T>(this ICustomAttributeProvider item) where T : Attribute
- {
- return (T) item.GetCustomAttributes(typeof (T), true)[0];
- }
- }
-}
\ No newline at end of file
product/utility/Builder.cs
@@ -1,7 +0,0 @@
-namespace utility
-{
- public interface Builder<T>
- {
- T build();
- }
-}
\ No newline at end of file
product/utility/Callback.cs
@@ -1,10 +0,0 @@
-namespace utility
-{
- public interface Callback : Command
- {
- }
-
- public interface Callback<T> : Command<T>
- {
- }
-}
\ No newline at end of file
product/utility/CallbackCommand.cs
@@ -1,6 +0,0 @@
-namespace utility
-{
- public interface CallbackCommand<T> : Command<Callback<T>>
- {
- }
-}
\ No newline at end of file
product/utility/ChainedCommand.cs
@@ -1,20 +0,0 @@
-namespace 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 +0,0 @@
-namespace 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,19 +0,0 @@
-namespace 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/utility/ChainedParameterizedCommand.cs
@@ -1,20 +0,0 @@
-namespace utility
-{
- public class ChainedCommand<T> : Command<T>
- {
- Command<T> left;
- Command<T> right;
-
- public ChainedCommand(Command<T> left, Command<T> right)
- {
- this.left = left;
- this.right = right;
- }
-
- public void run_against(T item)
- {
- left.run_against(item);
- right.run_against(item);
- }
- }
-}
\ No newline at end of file
product/utility/Clock.cs
@@ -1,36 +0,0 @@
-using System;
-
-namespace 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,12 +0,0 @@
-namespace utility
-{
- public interface Command
- {
- void run();
- }
-
- public interface Command<T>
- {
- void run_against(T item);
- }
-}
\ No newline at end of file
product/utility/CommandExtensions.cs
@@ -1,27 +0,0 @@
-using System;
-
-namespace 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));
- }
-
- static public Command<T> then<T>(this Command<T> left, Command<T> right)
- {
- return new ChainedCommand<T>(left, right);
- }
- }
-}
\ No newline at end of file
product/utility/ComparableExtensions.cs
@@ -1,17 +0,0 @@
-using System;
-
-namespace utility
-{
- static public class ComparableExtensions
- {
- static public bool is_before<T>(this T left, T right) where T : IComparable<T>
- {
- return left.CompareTo(right) < 0;
- }
-
- static public bool is_after<T>(this T left, T right) where T : IComparable<T>
- {
- return left.CompareTo(right) > 0;
- }
- }
-}
\ No newline at end of file
product/utility/ComponentFactory.cs
@@ -1,4 +0,0 @@
-namespace utility
-{
- public interface ComponentFactory<T> : Factory<T> where T : new() {}
-}
\ No newline at end of file
product/utility/Configuration.cs
@@ -1,7 +0,0 @@
-namespace utility
-{
- public interface Configuration<T>
- {
- void configure(T item);
- }
-}
\ No newline at end of file
product/utility/ConfigurationExtensions.cs
@@ -1,16 +0,0 @@
-namespace 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/Context.cs
@@ -1,34 +0,0 @@
-using System.Collections;
-
-namespace utility
-{
- public class Context : IContext
- {
- readonly IDictionary items;
-
- public Context(IDictionary items)
- {
- this.items = items;
- }
-
- public bool contains<T>(Key<T> key)
- {
- return key.is_found_in(items);
- }
-
- public void add<T>(Key<T> key, T value)
- {
- key.add_value_to(items, value);
- }
-
- public T value_for<T>(Key<T> key)
- {
- return key.parse_from(items);
- }
-
- public void remove<T>(Key<T> key)
- {
- key.remove_from(items);
- }
- }
-}
\ No newline at end of file
product/utility/ContextFactory.cs
@@ -1,10 +0,0 @@
-namespace utility
-{
- public class ContextFactory : IContextFactory
- {
- public IContext create_for(IScopedStorage storage)
- {
- return new Context(storage.provide_storage());
- }
- }
-}
\ No newline at end of file
product/utility/ConversionExtensions.cs
@@ -1,37 +0,0 @@
-using System;
-using System.Collections;
-
-namespace 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,85 +0,0 @@
-using System;
-using System.Globalization;
-
-namespace utility
-{
- [Serializable]
- public class Date : IComparable<Date>, IComparable, IEquatable<Date>
- {
- readonly long ticks;
- static public readonly Date First = new Date(DateTime.MinValue);
- static public readonly Date Last = new Date(DateTime.MaxValue);
-
- public Date( DateTime date)
- {
- this.ticks = date.Date.Ticks;
- }
-
- public DateTime to_date_time()
- {
- return new DateTime(ticks);
- }
-
- static public implicit operator Date(DateTime date)
- {
- return new Date(date);
- }
-
- 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/DateExtensions.cs
@@ -1,25 +0,0 @@
-namespace utility
-{
- static public class DateExtensions
- {
- static public Date plus_years(this Date date, int years)
- {
- return date.to_date_time().AddYears(years);
- }
-
- static public Date plus_days(this Date date, int days)
- {
- return date.to_date_time().AddDays(days);
- }
-
- static public Date minus_days(this Date date, int days)
- {
- return date.to_date_time().AddDays(-days);
- }
-
- static public Date add_months(this Date date, int months)
- {
- return date.to_date_time().AddMonths(months);
- }
- }
-}
\ No newline at end of file
product/utility/DefaultConstructorFactory.cs
@@ -1,10 +0,0 @@
-namespace 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,6 +0,0 @@
-using System;
-
-namespace utility
-{
- public interface DisposableCommand : Command, IDisposable {}
-}
\ No newline at end of file
product/utility/EmptyCallback.cs
@@ -1,9 +0,0 @@
-namespace utility
-{
- public class EmptyCallback<T> : Callback<T>, Callback
- {
- public void run_against(T item) {}
-
- public void run() {}
- }
-}
\ No newline at end of file
product/utility/EmptyCommand.cs
@@ -1,9 +0,0 @@
-namespace utility
-{
- public class EmptyCommand : Command
- {
- public void run()
- {
- }
- }
-}
\ No newline at end of file
product/utility/EnumerableExtensions.cs
@@ -1,46 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-
-namespace 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/ExpressionExtensions.cs
@@ -1,23 +0,0 @@
-using System;
-using System.Linq.Expressions;
-using System.Reflection;
-
-namespace utility
-{
- static public class ExpressionExtensions
- {
- static public PropertyInfo pick_property<T>(this Expression<Func<T, object>> expression)
- {
- return (PropertyInfo) member_expression(expression).Member;
- }
-
- static MemberExpression member_expression<T>(Expression<Func<T, object>> expression)
- {
- if (expression.Body.NodeType == ExpressionType.Convert)
- return ((UnaryExpression) expression.Body).Operand as MemberExpression;
- if (expression.Body.NodeType == ExpressionType.MemberAccess)
- return expression.Body as MemberExpression;
- throw new NotImplementedException();
- }
- }
-}
\ No newline at end of file
product/utility/Factory.cs
@@ -1,7 +0,0 @@
-namespace utility
-{
- public interface Factory<T>
- {
- T create();
- }
-}
\ No newline at end of file
product/utility/FactoryDelegate.cs
@@ -1,6 +0,0 @@
-namespace utility
-{
- public delegate Out FactoryDelegate<In, Out>(In input);
-
- public delegate Out FactoryDelegate<Out>();
-}
\ No newline at end of file
product/utility/FilteredVisitor.cs
@@ -1,19 +0,0 @@
-namespace 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 +0,0 @@
-using System;
-
-namespace 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 +0,0 @@
-using System;
-
-namespace 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/IContext.cs
@@ -1,10 +0,0 @@
-namespace utility
-{
- public interface IContext
- {
- bool contains<T>(Key<T> key);
- void add<T>(Key<T> key, T value);
- T value_for<T>(Key<T> key);
- void remove<T>(Key<T> key);
- }
-}
\ No newline at end of file
product/utility/IContextFactory.cs
@@ -1,7 +0,0 @@
-namespace utility
-{
- public interface IContextFactory
- {
- IContext create_for(IScopedStorage storage);
- }
-}
\ No newline at end of file
product/utility/Id.cs
@@ -1,46 +0,0 @@
-using System;
-
-namespace utility
-{
- [Serializable]
- public class Id<T>
- {
- static public readonly Id<T> Default = new Id<T>(default(T));
- public T id { get; private set; }
-
- public Id(T id)
- {
- this.id = id;
- }
-
- static public implicit operator Id<T>(T id)
- {
- return new Id<T>(id);
- }
-
- static public implicit operator T(Id<T> id)
- {
- return id.id;
- }
-
- public bool Equals(Id<T> other)
- {
- if (ReferenceEquals(null, other)) return false;
- if (ReferenceEquals(this, other)) return true;
- return Equals(other.id, id);
- }
-
- public override bool Equals(object obj)
- {
- if (ReferenceEquals(null, obj)) return false;
- if (ReferenceEquals(this, obj)) return true;
- if (obj.GetType() != typeof (Id<T>)) return false;
- return Equals((Id<T>) obj);
- }
-
- public override int GetHashCode()
- {
- return id.GetHashCode();
- }
- }
-}
\ No newline at end of file
product/utility/Identifiable.cs
@@ -1,7 +0,0 @@
-namespace utility
-{
- public interface Identifiable<T>
- {
- Id<T> id { get; }
- }
-}
\ No newline at end of file
product/utility/Import.cs
@@ -1,7 +0,0 @@
-namespace utility
-{
- public interface Import<T>
- {
- void import(T item);
- }
-}
\ No newline at end of file
product/utility/IScopedStorage.cs
@@ -1,9 +0,0 @@
-using System.Collections;
-
-namespace utility
-{
- public interface IScopedStorage
- {
- IDictionary provide_storage();
- }
-}
\ No newline at end of file
product/utility/Key.cs
@@ -1,12 +0,0 @@
-using System.Collections;
-
-namespace utility
-{
- public interface Key<T>
- {
- bool is_found_in(IDictionary items);
- T parse_from(IDictionary items);
- void remove_from(IDictionary items);
- void add_value_to(IDictionary items, T value);
- }
-}
\ No newline at end of file
product/utility/ListExtensions.cs
@@ -1,42 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-
-namespace 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,12 +0,0 @@
-namespace utility
-{
- public interface Mapper<Input, Output>
- {
- Output map_from(Input item);
- }
-
- public interface Mapper
- {
- Output map_from<Input, Output>(Input item);
- }
-}
\ No newline at end of file
product/utility/MappingExtensions.cs
@@ -1,48 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-
-namespace utility
-{
- static public class MappingExtensions
- {
- static public Output map_using<Input, Output>(this Input item, Converter<Input, Output> conversion)
- {
- return conversion(item);
- }
-
- static public Output map_using<Input, Output>(this Input item, Mapper<Input, Output> mapper)
- {
- return map_using(item, x => mapper.map_from(x));
- }
-
- static public Output map_using<Input, Output>(this Input item, Mapper mapper)
- {
- return map_using(item, x => mapper.map_from<Input, Output>(x));
- }
-
- static public IEnumerable<Output> map_all_using<Input, Output>(this IEnumerable<Input> items,
- Converter<Input, Output> mapper)
- {
- return null == items ? Enumerable.Empty<Output>() : items.Select(x => mapper(x));
- }
-
- static public 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));
- }
-
- static public IEnumerable<Output> map_all_using<Input, Output>(this IEnumerable<Input> items,
- Mapper mapper)
- {
- return map_all_using(items, x => mapper.map_from<Input, Output>(x));
- }
-
- static public 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 +0,0 @@
-namespace utility
-{
- public interface Notification
- {
- void notify(params NotificationMessage[] messages);
- }
-}
\ No newline at end of file
product/utility/NotificationMessage.cs
@@ -1,42 +0,0 @@
-namespace 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 +0,0 @@
-namespace 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 +0,0 @@
-using System;
-
-namespace 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/Observer.cs
@@ -1,4 +0,0 @@
-namespace utility
-{
- public delegate void Observer<T>(T item);
-}
\ No newline at end of file
product/utility/OrSpecification.cs
@@ -1,19 +0,0 @@
-namespace 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/Parser.cs
@@ -1,7 +0,0 @@
-namespace utility
-{
- public interface Parser<T>
- {
- T parse();
- }
-}
\ No newline at end of file
product/utility/Percent.cs
@@ -1,62 +0,0 @@
-using System;
-using System.Globalization;
-
-namespace 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 +0,0 @@
-using System;
-
-namespace 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,12 +0,0 @@
-namespace utility
-{
- public interface Query<TOutput>
- {
- TOutput fetch();
- }
-
- public interface Query<TInput, TOutput>
- {
- TOutput fetch(TInput item);
- }
-}
\ No newline at end of file
product/utility/Registry.cs
@@ -1,9 +0,0 @@
-using System.Collections.Generic;
-
-namespace utility
-{
- public interface Registry<T> : IEnumerable<T>
- {
- IEnumerable<T> all();
- }
-}
\ No newline at end of file
product/utility/RegistryExtensions.cs
@@ -1,29 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-
-namespace 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".format(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/SingletonScopedStorage.cs
@@ -1,14 +0,0 @@
-using System.Collections;
-
-namespace utility
-{
- public class SingletonScopedStorage : IScopedStorage
- {
- static readonly IDictionary storage = new Hashtable();
-
- public IDictionary provide_storage()
- {
- return storage;
- }
- }
-}
\ No newline at end of file
product/utility/Specification.cs
@@ -1,7 +0,0 @@
-namespace utility
-{
- public interface Specification<T>
- {
- bool is_satisfied_by(T item);
- }
-}
\ No newline at end of file
product/utility/SpecificationExtensions.cs
@@ -1,40 +0,0 @@
-using System;
-using System.Collections.Generic;
-
-namespace utility
-{
- static public class SpecificationExtensions
- {
- 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;
- }
-
- static public bool satisfies<T>(this T item_to_interrogate, Predicate<T> criteria_to_satisfy)
- {
- return criteria_to_satisfy(item_to_interrogate);
- }
-
- 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);
- }
-
- 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));
- }
-
- 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));
- }
-
- static public Specification<T> not<T>(this Specification<T> original)
- {
- return new PredicateSpecification<T>(x => !original.is_satisfied_by(x));
- }
- }
-}
\ No newline at end of file
product/utility/State.cs
@@ -1,6 +0,0 @@
-namespace utility
-{
- public interface State
- {
- }
-}
\ No newline at end of file
product/utility/StringExtensions.cs
@@ -1,25 +0,0 @@
-namespace utility
-{
- static public class StringExtensions
- {
- static public string format(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}".format(item);
- }
- }
-}
\ No newline at end of file
product/utility/SubjectOf.cs
@@ -1,7 +0,0 @@
-namespace utility
-{
- public interface SubjectOf<State> where State : utility.State
- {
- void change_state_to(State new_state);
- }
-}
\ No newline at end of file
product/utility/TypedKey.cs
@@ -1,50 +0,0 @@
-using System.Collections;
-
-namespace utility
-{
- public class TypedKey<T> : Key<T>
- {
- public bool is_found_in(IDictionary items)
- {
- return items.Contains(create_key());
- }
-
- public T parse_from(IDictionary items)
- {
- return (T) items[create_key()];
- }
-
- public void remove_from(IDictionary items)
- {
- if (is_found_in(items)) items.Remove(create_key());
- }
-
- public void add_value_to(IDictionary items, T value)
- {
- items[create_key()] = value;
- }
-
- public bool Equals(TypedKey<T> obj)
- {
- return !ReferenceEquals(null, obj);
- }
-
- public override bool Equals(object obj)
- {
- if (ReferenceEquals(null, obj)) return false;
- if (ReferenceEquals(this, obj)) return true;
- if (obj.GetType() != typeof (TypedKey<T>)) return false;
- return Equals((TypedKey<T>) obj);
- }
-
- public override int GetHashCode()
- {
- return GetType().GetHashCode();
- }
-
- string create_key()
- {
- return GetType().FullName;
- }
- }
-}
\ No newline at end of file
product/utility/TypeExtensions.cs
@@ -1,40 +0,0 @@
-using System;
-using System.Linq;
-using System.Reflection;
-
-namespace 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
@@ -1,123 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProductVersion>8.0.30703</ProductVersion>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{39B95E47-DA9C-4C80-A395-515600C55D4B}</ProjectGuid>
- <OutputType>Library</OutputType>
- <AppDesignerFolder>Properties</AppDesignerFolder>
- <RootNamespace>utility</RootNamespace>
- <AssemblyName>utility</AssemblyName>
- <TargetFrameworkVersion>v4.0</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="System" />
- <Reference Include="System.Core" />
- <Reference Include="System.Xml.Linq" />
- <Reference Include="System.Data.DataSetExtensions" />
- <Reference Include="Microsoft.CSharp" />
- <Reference Include="System.Data" />
- <Reference Include="System.Xml" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="AndSpecification.cs" />
- <Compile Include="AnonymousCommand.cs" />
- <Compile Include="AnonymousDisposable.cs" />
- <Compile Include="AnonymousMapper.cs" />
- <Compile Include="AttributeExtensions.cs" />
- <Compile Include="Builder.cs" />
- <Compile Include="Callback.cs" />
- <Compile Include="CallbackCommand.cs" />
- <Compile Include="ChainedCommand.cs" />
- <Compile Include="ChainedConfiguration.cs" />
- <Compile Include="ChainedMapper.cs" />
- <Compile Include="ChainedParameterizedCommand.cs" />
- <Compile Include="Clock.cs" />
- <Compile Include="Command.cs" />
- <Compile Include="CommandExtensions.cs" />
- <Compile Include="ComparableExtensions.cs" />
- <Compile Include="ComponentFactory.cs" />
- <Compile Include="Configuration.cs" />
- <Compile Include="ConfigurationExtensions.cs" />
- <Compile Include="Context.cs" />
- <Compile Include="ContextFactory.cs" />
- <Compile Include="ConversionExtensions.cs" />
- <Compile Include="Date.cs" />
- <Compile Include="DateExtensions.cs" />
- <Compile Include="DefaultConstructorFactory.cs" />
- <Compile Include="DisposableCommand.cs" />
- <Compile Include="EmptyCallback.cs" />
- <Compile Include="EmptyCommand.cs" />
- <Compile Include="EnumerableExtensions.cs" />
- <Compile Include="ExpressionExtensions.cs" />
- <Compile Include="Factory.cs" />
- <Compile Include="FactoryDelegate.cs" />
- <Compile Include="FilteredVisitor.cs" />
- <Compile Include="FuncExtensions.cs" />
- <Compile Include="FuncSpecification.cs" />
- <Compile Include="IContext.cs" />
- <Compile Include="IContextFactory.cs" />
- <Compile Include="Id.cs" />
- <Compile Include="Identifiable.cs" />
- <Compile Include="Key.cs" />
- <Compile Include="Import.cs" />
- <Compile Include="IScopedStorage.cs" />
- <Compile Include="ListExtensions.cs" />
- <Compile Include="Mapper.cs" />
- <Compile Include="MappingExtensions.cs" />
- <Compile Include="Notification.cs" />
- <Compile Include="NotificationMessage.cs" />
- <Compile Include="NotSpecification.cs" />
- <Compile Include="NumericConversions.cs" />
- <Compile Include="Observer.cs" />
- <Compile Include="OrSpecification.cs" />
- <Compile Include="Parser.cs" />
- <Compile Include="Percent.cs" />
- <Compile Include="PredicateSpecification.cs" />
- <Compile Include="Properties\AssemblyInfo.cs" />
- <Compile Include="Query.cs" />
- <Compile Include="Registry.cs" />
- <Compile Include="RegistryExtensions.cs" />
- <Compile Include="SingletonScopedStorage.cs" />
- <Compile Include="Specification.cs" />
- <Compile Include="SpecificationExtensions.cs" />
- <Compile Include="State.cs" />
- <Compile Include="StringExtensions.cs" />
- <Compile Include="SubjectOf.cs" />
- <Compile Include="TypedKey.cs" />
- <Compile Include="TypeExtensions.cs" />
- <Compile Include="ValueReturningVisitor.cs" />
- <Compile Include="Visitable.cs" />
- <Compile Include="Visitor.cs" />
- <Compile Include="VisitorExtensions.cs" />
- <Compile Include="Year.cs" />
- </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/utility/ValueReturningVisitor.cs
@@ -1,8 +0,0 @@
-namespace utility
-{
- public interface ValueReturningVisitor<Value, T> : Visitor<T>
- {
- Value value { get; }
- void reset();
- }
-}
\ No newline at end of file
product/utility/Visitable.cs
@@ -1,7 +0,0 @@
-namespace utility
-{
- public interface Visitable<T>
- {
- void accept(Visitor<T> visitor);
- }
-}
\ No newline at end of file
product/utility/Visitor.cs
@@ -1,7 +0,0 @@
-namespace utility
-{
- public interface Visitor<T>
- {
- void visit(T item_to_visit);
- }
-}
\ No newline at end of file
product/utility/VisitorExtensions.cs
@@ -1,19 +0,0 @@
-using System.Collections.Generic;
-
-namespace 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/utility/Year.cs
@@ -1,53 +0,0 @@
-using System;
-
-namespace 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
support/default.build
@@ -23,7 +23,7 @@
<delete dir="${tmp.dir}" />
</target>
- <target name="init" depends="clean">
+ <target name="init" depends="clean, create.configs">
<mkdir dir="${tmp.dir}" />
</target>
@@ -74,4 +74,17 @@
<property name="xunit.arguments" value="-t --html ${tmp.dir} ${tmp.dir}/specs.dll" />
<call target="run.test" />
</target>
+
+ <target name="expand.template.file">
+ <copy file="${target}.template" tofile="${target}" overwrite="true">
+ <filterchain>
+ <expandproperties />
+ </filterchain>
+ </copy>
+ </target>
+
+ <target name="create.configs">
+ <property name="target" value="${src.dir}/desktop.ui/Properties/AssemblyInfo.cs" />
+ <call target="expand.template.file" />
+ </target>
</project>