public object Execute(dynamic query) { Type queryType = query.GetType(); Type resultType = GetQueryResultType(queryType); Type queryHandlerType = typeof(IQueryHandler <,>).MakeGenericType(queryType, resultType); dynamic queryHandler = Bootstrapper.GetInstance(queryHandlerType); return(queryHandler.Handle(query)); }
public object Execute(dynamic command) { Type commandHandlerType = typeof(ICommandHandler <>).MakeGenericType(command.GetType()); dynamic commandHandler = Bootstrapper.GetInstance(commandHandlerType); commandHandler.Handle(command); // Instead of returning the output property of a command, we just return the complete command. // There is some overhead in this, but is of course much easier than returning a part of the command. return(command); }
private static TResult Execute <TQuery, TResult>(TQuery query) where TQuery : IQuery <TResult> { var handler = Bootstrapper.GetInstance <IQueryHandler <TQuery, TResult> >(); return(handler.Handle(query)); }