Skip to content

Instantly share code, notes, and snippets.

@yevhen
Forked from ashic/gist:1717892
Created February 1, 2012 16:37
Show Gist options
  • Save yevhen/1717908 to your computer and use it in GitHub Desktop.
Save yevhen/1717908 to your computer and use it in GitHub Desktop.
public class SomeCommandHandler
{
uow? where are you?
public void Handle(SomeCommand command)
{
var agg = uow.GetById(command.AggId);
agg.Foo();
}
}
public class UoWWrapper
{
public UoWWrapper(Action<object> next)
{
_next = next;
}
public void Handle(object command)
{
var uow = new UoW()
{
_next(command);
uow.Commit();
}
}
}
public class CompositionRoot
{
public void Setup()
{
var bus = new Bus();
var someHandler = new SomeCommandHandler().Handle;
var wrapped = new UoWWrapper(someHandler).Handle;
bus.RegisterCommand<SomeCommand>(wrapped);
}
}
//Some widening - narrowing may be needed between Action<T> and Action<object> but that's trivial
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment