-
-
Save yevhen/1717908 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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