< 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{
 611    private readonly IDictionary<Type, string> _typeAliasDictionary = new Dictionary<Type, string>();
 12
 13    /// <summary>
 14    /// Constructor.
 15    /// </summary>
 616    public TypeAliasRegistry()
 17    {
 618        this.RegisterType<object>("any");
 619        this.RegisterType<ExpandoObject>("any");
 620        this.RegisterType<string>("string");
 621        this.RegisterType<bool>("boolean");
 622        this.RegisterType<short>("number");
 623        this.RegisterType<int>("number");
 624        this.RegisterType<long>("number");
 625        this.RegisterType<decimal>("Decimal");
 626        this.RegisterType<float>("Single");
 627        this.RegisterType<double>("Double");
 628        this.RegisterType<byte[]>("Buffer");
 629        this.RegisterType<Stream>("Stream");
 630        this.RegisterType<Guid>("Guid");
 631        this.RegisterType<DateTime>("Date");
 632        this.RegisterType<DateTimeOffset>("Date");
 633        this.RegisterType<DateOnly>("Date");
 634        this.RegisterType<TimeOnly>("Date");
 635        this.RegisterType<IDictionary<string, object>>("ObjectDictionary");
 636        this.RegisterType<LogPersistenceMode>("LogPersistenceMode");
 637    }
 38
 39    /// <inheritdoc />
 40    public void RegisterType(Type type, string alias)
 41    {
 20142        _typeAliasDictionary[type] = alias;
 20143    }
 44
 45    /// <inheritdoc />
 046    public bool TryGetAlias(Type type, out string alias) => _typeAliasDictionary.TryGetValue(type, out alias!);
 47}