< Summary

Information
Class: Elsa.Mediator.Middleware.Request.MiddlewareExtensions
Assembly: Elsa.Mediator
File(s): /home/runner/work/elsa-core/elsa-core/src/common/Elsa.Mediator/Middleware/Request/MiddlewareExtensions.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 8
Coverable lines: 8
Total lines: 29
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 2
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
UseMiddleware(...)0%620%

File(s)

/home/runner/work/elsa-core/elsa-core/src/common/Elsa.Mediator/Middleware/Request/MiddlewareExtensions.cs

#LineLine coverage
 1using Elsa.Mediator.Middleware.Request.Contracts;
 2using Microsoft.Extensions.DependencyInjection;
 3
 4namespace Elsa.Mediator.Middleware.Request;
 5
 6/// <summary>
 7/// Provides a set of static methods for building a request pipeline.
 8/// </summary>
 9public static class MiddlewareExtensions
 10{
 11    /// <summary>
 12    /// Adds a request handler invoker middleware to the request pipeline.
 13    /// </summary>
 14    /// <param name="builder">The request pipeline builder.</param>
 15    /// <param name="args">The arguments to pass to the middleware constructor.</param>
 16    /// <typeparam name="TMiddleware">The middleware type.</typeparam>
 17    public static IRequestPipelineBuilder UseMiddleware<TMiddleware>(this IRequestPipelineBuilder builder, params object
 18    {
 019        var middleware = typeof(TMiddleware);
 20
 021        return builder.Use(next =>
 022        {
 023            var invokeMethod = MiddlewareHelpers.GetInvokeMethod(middleware);
 024            var ctorParams = new[] { next }.Concat(args).Select(x => x!).ToArray();
 025            var instance = ActivatorUtilities.CreateInstance(builder.ApplicationServices, middleware, ctorParams);
 026            return (RequestMiddlewareDelegate)invokeMethod.CreateDelegate(typeof(RequestMiddlewareDelegate), instance);
 027        });
 28    }
 29}