< Summary

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

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
UseMiddleware(...)100%22100%

File(s)

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

#LineLine coverage
 1using Elsa.Mediator.Middleware.Notification.Contracts;
 2using Microsoft.Extensions.DependencyInjection;
 3
 4namespace Elsa.Mediator.Middleware.Notification;
 5
 6/// <summary>
 7/// Contains extension methods for <see cref="INotificationPipelineBuilder"/>.
 8/// </summary>
 9public static class MiddlewareExtensions
 10{
 11    /// <summary>
 12    /// Adds a middleware to the notification pipeline.
 13    /// </summary>
 14    /// <param name="builder">The notification 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 INotificationPipelineBuilder UseMiddleware<TMiddleware>(this INotificationPipelineBuilder builder, par
 18    {
 119        var middleware = typeof(TMiddleware);
 20
 121        return builder.Use(next =>
 122        {
 123            var invokeMethod = MiddlewareHelpers.GetInvokeMethod(middleware);
 224            var ctorParams = new[] { next }.Concat(args).Select(x => x).ToArray();
 125            var instance = ActivatorUtilities.CreateInstance(builder.ApplicationServices, middleware, ctorParams);
 126            return (NotificationMiddlewareDelegate)invokeMethod.CreateDelegate(typeof(NotificationMiddlewareDelegate), i
 127        });
 28    }
 29}