< Summary

Information
Class: Elsa.Expressions.JavaScript.Services.TypeAliasRegistry
Assembly: Elsa.Expressions.JavaScript
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Expressions.JavaScript/Services/TypeAliasRegistry.cs
Line coverage
96%
Covered lines: 24
Uncovered lines: 1
Coverable lines: 25
Total lines: 47
Line coverage: 96%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor()100%11100%
RegisterType(...)100%11100%
TryGetAlias(...)100%210%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Expressions.JavaScript/Services/TypeAliasRegistry.cs

#LineLine coverage
 1using System.Dynamic;
 2using Elsa.Expressions.JavaScript.Contracts;
 3using Elsa.Expressions.JavaScript.Extensions;
 4using Elsa.Workflows.LogPersistence;
 5
 6namespace Elsa.Expressions.JavaScript.Services;
 7
 8/// <inheritdoc />
 9public class TypeAliasRegistry : ITypeAliasRegistry
 10{
 1011    private readonly IDictionary<Type, string> _typeAliasDictionary = new Dictionary<Type, string>();
 12
 13    /// <summary>
 14    /// Constructor.
 15    /// </summary>
 1016    public TypeAliasRegistry()
 17    {
 1018        this.RegisterType<object>("any");
 1019        this.RegisterType<ExpandoObject>("any");
 1020        this.RegisterType<string>("string");
 1021        this.RegisterType<bool>("boolean");
 1022        this.RegisterType<short>("number");
 1023        this.RegisterType<int>("number");
 1024        this.RegisterType<long>("number");
 1025        this.RegisterType<decimal>("Decimal");
 1026        this.RegisterType<float>("Single");
 1027        this.RegisterType<double>("Double");
 1028        this.RegisterType<byte[]>("Buffer");
 1029        this.RegisterType<Stream>("Stream");
 1030        this.RegisterType<Guid>("Guid");
 1031        this.RegisterType<DateTime>("Date");
 1032        this.RegisterType<DateTimeOffset>("Date");
 1033        this.RegisterType<DateOnly>("Date");
 1034        this.RegisterType<TimeOnly>("Date");
 1035        this.RegisterType<IDictionary<string, object>>("ObjectDictionary");
 1036        this.RegisterType<LogPersistenceMode>("LogPersistenceMode");
 1037    }
 38
 39    /// <inheritdoc />
 40    public void RegisterType(Type type, string alias)
 41    {
 39342        _typeAliasDictionary[type] = alias;
 39343    }
 44
 45    /// <inheritdoc />
 046    public bool TryGetAlias(Type type, out string alias) => _typeAliasDictionary.TryGetValue(type, out alias!);
 47}