< Summary

Information
Class: ClientManager.Worker.Administration.ServiceCollectionExtensions
Assembly: ClientManager.Worker
File(s): /home/runner/work/ClientManagerDemo/ClientManagerDemo/src/ClientManager/ClientManager.Worker/Administration/ServiceCollectionExtensions.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 9
Coverable lines: 9
Total lines: 21
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 8
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
AddMessageHandlers(...)0%7280%

File(s)

/home/runner/work/ClientManagerDemo/ClientManagerDemo/src/ClientManager/ClientManager.Worker/Administration/ServiceCollectionExtensions.cs

#LineLine coverage
 1using System.Reflection;
 2using ClientManager.Shared.Messaging;
 3
 4namespace ClientManager.Worker.Administration;
 5
 6public static class ServiceCollectionExtensions
 7{
 8    public static void AddMessageHandlers(this IServiceCollection services, params Assembly[] assemblies)
 9    {
 010        var handlerInterface = typeof(IHandleMessage<>);
 11
 012        var registrations =
 013            from type in assemblies.SelectMany(a => a.GetTypes())
 014            from iface in type.GetInterfaces()
 015            where !type.IsAbstract && !type.IsInterface && iface.IsGenericType && iface.GetGenericTypeDefinition() == ha
 016            select new { Service = iface, Implementation = type };
 17
 018        foreach (var r in registrations)
 019            services.AddScoped(r.Service, r.Implementation);
 020    }
 21}