Skip to content

Instantly share code, notes, and snippets.

@agross
Created May 10, 2010 18:00
Show Gist options
  • Save agross/396322 to your computer and use it in GitHub Desktop.
Save agross/396322 to your computer and use it in GitHub Desktop.
public interface ICommandMessageHandler<TCommand>
{
void Execute(TCommand message);
}
public interface ICommandMessageHandler : ICommandMessageHandler<object>
{
}
public abstract class Command<T> : ICommandMessageHandler
{
public void Execute(object message)
{
Execute((T) message);
}
protected abstract void Execute(T message);
}
public interface IAmSynchronized : ICommandMessageHandler
{
}
public class SynchronizedCommandDecorator : ICommandMessageHandler
{
readonly IAmSynchronized _handler;
readonly ISynchronizer _synchronizer;
public SynchronizedCommandDecorator(IAmSynchronized handler, ISynchronizer synchronizer)
{
_handler = handler;
_synchronizer = synchronizer;
}
public void Execute(object message)
{
// call _handler
}
}
public class ConfigureEnvironmentCommand : Command<ConfigureEnvironmentMessage>
{
protected override void Execute(ConfigureEnvironmentMessage message)
{
}
}
public class ConfigureEnvironmentMessage
{
}
public class ConfigureEnvironmentCommandSync : Command<ConfigureEnvironmentMessage>, IAmSynchronized
{
protected override void Execute(ConfigureEnvironmentMessage message)
{
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment