Created
October 26, 2012 21:33
-
-
Save janderit/3961698 to your computer and use it in GitHub Desktop.
Closures, commandhandlers und co
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
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