Last active
December 24, 2015 23:59
-
-
Save kristofclaes/6884007 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 InschrijvingenController : Controller | |
{ | |
private readonly ICommandDispatcher dispatcher; | |
public InschrijvingenController(ICommandDispatcher dispatcher) | |
{ | |
this.dispatcher = dispatcher; | |
} | |
public ActionResult Create(CreateModel model) | |
{ | |
RegistreerNieuweInschrijvingCommand command = CreateCommand(model); | |
dispatcher.ExecuteCommand(command); | |
return RedirectToAction("Index"); | |
} | |
private RegistreerNieuweInschrijvingCommand CreateCommand(CreateModel model) { ... } | |
} | |
public interface ICommandDispatcher | |
{ | |
void ExecuteCommand<T>(T command) where T : class; | |
} | |
public class CommandDispatcher | |
{ | |
private readonly IKernel kernel; | |
public CommandDispatcher(IKernel kernel) | |
{ | |
this.kernel = kernel; | |
} | |
public void ExecuteCommand<T>(T command) where T : class | |
{ | |
var handler = kernel.Get<ICommandHandler<T>>(); | |
handler.Handle(command); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment