public IReadOnlyList <PreparedInvocation <TResult> > PrepareInvocations <TResult>( object request, CancellationToken cancellationToken = default) { if (!_inspector.TryGetMethodsReturning(request.GetType(), typeof(TResult), _collisionStrategy, out var methods)) { throw new InvalidOperationException( $"Type '{_inspector.Type.Name}' doesn't support accepting " + $"requests of type '{request.GetType().Name}' and " + $"returning '{typeof(TResult).Name}'."); } var preparedInvocations = methods.Select(method => { var recipientInstance = _factory.Get(); var acceptedCancellationToken = _methodAnalyzer.AcceptsCancellationToken(method); Func <object?> invocation = acceptedCancellationToken ? () => method.Invoke(recipientInstance, new object?[] { request, cancellationToken }) : () => method.Invoke(recipientInstance, new object?[] { request }); return(new PreparedInvocation <TResult>(invocation, acceptedCancellationToken)); }); return(preparedInvocations.ToArray()); }