< 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{
 411    private readonly IDictionary<Type, string> _typeAliasDictionary = new Dictionary<Type, string>();
 12
 13    /// <summary>
 14    /// Constructor.
 15    /// </summary>
 416    public TypeAliasRegistry()
 17    {
 418        this.RegisterType<object>("any");
 419        this.RegisterType<ExpandoObject>("any");
 420        this.RegisterType<string>("string");
 421        this.RegisterType<bool>("boolean");
 422        this.RegisterType<short>("number");
 423        this.RegisterType<int>("number");
 424        this.RegisterType<long>("number");
 425        this.RegisterType<decimal>("Decimal");
 426        this.RegisterType<float>("Single");
 427        this.RegisterType<double>("Double");
 428        this.RegisterType<byte[]>("Buffer");
 429        this.RegisterType<Stream>("Stream");
 430        this.RegisterType<Guid>("Guid");
 431        this.RegisterType<DateTime>("Date");
 432        this.RegisterType<DateTimeOffset>("Date");
 433        this.RegisterType<DateOnly>("Date");
 434        this.RegisterType<TimeOnly>("Date");
 435        this.RegisterType<IDictionary<string, object>>("ObjectDictionary");
 436        this.RegisterType<LogPersistenceMode>("LogPersistenceMode");
 437    }
 38
 39    /// <inheritdoc />
 40    public void RegisterType(Type type, string alias)
 41    {
 10542        _typeAliasDictionary[type] = alias;
 10543    }
 44
 45    /// <inheritdoc />
 046    public bool TryGetAlias(Type type, out string alias) => _typeAliasDictionary.TryGetValue(type, out alias!);
 47}