Skip to content

Instantly share code, notes, and snippets.

@bmeredith
Last active June 2, 2017 11:52
Show Gist options
  • Save bmeredith/99ec50eced67934a9670 to your computer and use it in GitHub Desktop.
Save bmeredith/99ec50eced67934a9670 to your computer and use it in GitHub Desktop.
public class AutofacCommandDispatcher : ICommandDispatcher
{
private readonly IComponentContext _context;
public AutofacCommandDispatcher(IComponentContext context)
{
_context = context;
}
public void Dispatch(ICommand command)
{
var handlerType = typeof(ICommandHandler<>).MakeGenericType(command.GetType());
dynamic handler = _context.Resolve(handlerType);
handler.Handle((dynamic)command);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment