public TReturnType Send(object command, CancellationToken token)
    {
        var commandType = Guard.NotNull(command, nameof(command)).GetType();
        var handlerType = HandlerTypeFor(commandType);
        var handler     = GetHandler(handlerType) ?? throw UnresolvedCommandHandler.Type(handlerType);

        return(Handle(handlerType, commandType)(handler, command, token));
    }
 private Func <object, object, CancellationToken, TReturnType> Handle(Type handlerType, Type commandType)
 {
     if (!handlers.TryGetValue(commandType, out var handle))
     {
         var method = GetMethod(handlerType, commandType)
                      ?? throw UnresolvedCommandHandler.Method(typeof(TReturnType), handlerType, HandlerMethod, commandType);
         handle = GetExpression(method).Compile();
         handlers[commandType] = handle;
     }
     return(handle);
 }