< Summary

Information
Class: Elsa.Expressions.JavaScript.HostedServices.RegisterVariableTypesWithJavaScriptHostedService
Assembly: Elsa.Expressions.JavaScript
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Expressions.JavaScript/HostedServices/RegisterVariableTypesWithJavaScriptHostedService.cs
Line coverage
100%
Covered lines: 8
Uncovered lines: 0
Coverable lines: 8
Total lines: 36
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
.ctor(...)100%11100%
StartAsync(...)100%22100%
StopAsync(...)100%11100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Expressions.JavaScript/HostedServices/RegisterVariableTypesWithJavaScriptHostedService.cs

#LineLine coverage
 1using Elsa.Expressions.JavaScript.Contracts;
 2using Elsa.Workflows.Management.Options;
 3using Microsoft.Extensions.Hosting;
 4using Microsoft.Extensions.Options;
 5
 6namespace Elsa.Expressions.JavaScript.HostedServices;
 7
 8/// <summary>
 9/// Registers variable types with the JavaScript type alias registry
 10/// </summary>
 11public class RegisterVariableTypesWithJavaScriptHostedService : IHostedService
 12{
 13    private readonly ITypeAliasRegistry _typeAliasRegistry;
 14    private readonly IOptions<ManagementOptions> _managementOptions;
 15
 16    /// <summary>
 17    /// Initializes a new instance of the <see cref="RegisterVariableTypesWithJavaScriptHostedService"/> class.
 18    /// </summary>
 119    public RegisterVariableTypesWithJavaScriptHostedService(ITypeAliasRegistry typeAliasRegistry, IOptions<ManagementOpt
 20    {
 121        _typeAliasRegistry = typeAliasRegistry;
 122        _managementOptions = managementOptions;
 123    }
 24
 25    /// <inheritdoc />
 26    public Task StartAsync(CancellationToken cancellationToken)
 27    {
 6028        foreach (var variableDescriptor in _managementOptions.Value.VariableDescriptors)
 2929            _typeAliasRegistry.RegisterType(variableDescriptor.Type, variableDescriptor.Type.Name);
 30
 131        return Task.CompletedTask;
 32    }
 33
 34    /// <inheritdoc />
 235    public Task StopAsync(CancellationToken cancellationToken) => Task.CompletedTask;
 36}