Instantly share code, notes, and snippets.

Embed
What would you like to do?
Closures, commandhandlers und co
class EventStore{
void Save(Guid commandId, Event[] events);
}
class EventPublisher{
void Save(Guid senderSession, Event[] events);
}
delegate EventCommitter(Guid commandId, Event[] events);
class CommandHandlers{
CommandHandlers(EventCommitter onCommit){_onCommit=onCommit;}
void Handle(Somecommand cmd){
//...
_onCommit(cmd.Id, UoW.GetUncommittedEvents);
}
}
public void ConfigureSession(Guid sessionId){
chs = new CommandHandlers(
(id, events)=>{
eventStore.Save(id, events);
eventPublisher.Publish(sessionId, events);
}
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment