< Summary

Information
Class: Elsa.Expressions.Options.ExpressionOptions
Assembly: Elsa.Expressions
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Expressions/Options/ExpressionOptions.cs
Line coverage
100%
Covered lines: 31
Uncovered lines: 0
Coverable lines: 31
Total lines: 62
Line coverage: 100%
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%
get_AliasTypeDictionary()100%11100%
RegisterTypeAlias(...)100%11100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Expressions/Options/ExpressionOptions.cs

#LineLine coverage
 1using System.Collections.ObjectModel;
 2using System.Dynamic;
 3using System.Text.Json;
 4using System.Text.Json.Nodes;
 5using Elsa.Extensions;
 6
 7namespace Elsa.Expressions.Options;
 8
 9/// <summary>
 10/// Options for the expression feature.
 11/// </summary>
 12public class ExpressionOptions
 13{
 914    private readonly IDictionary<string, Type> _aliasTypeDictionary = new Dictionary<string, Type>();
 15
 16    /// <summary>
 17    /// Initializes a new instance of the <see cref="ExpressionOptions"/> class.
 18    /// </summary>
 919    public ExpressionOptions()
 20    {
 921        AliasTypeDictionary = new ReadOnlyDictionary<string, Type>(_aliasTypeDictionary);
 22
 923        this.AddTypeAlias<short>("Int16");
 924        this.AddTypeAlias<int>("Int32");
 925        this.AddTypeAlias<long>("Int64");
 926        this.AddTypeAlias<long>("Long");
 927        this.AddTypeAlias<float>("Single");
 928        this.AddTypeAlias<object>("Object");
 929        this.AddTypeAlias<string>("String");
 930        this.AddTypeAlias<bool>("Boolean");
 931        this.AddTypeAlias<decimal>("Decimal");
 932        this.AddTypeAlias<double>("Double");
 933        this.AddTypeAlias<byte[]>("ByteArray");
 934        this.AddTypeAlias<Guid>();
 935        this.AddTypeAlias<DateTime>();
 936        this.AddTypeAlias<DateTimeOffset>();
 937        this.AddTypeAlias<TimeSpan>();
 938        this.AddTypeAlias<Stream>();
 939        this.AddTypeAlias<ExpandoObject>("JSON");
 940        this.AddTypeAlias<JsonElement>();
 941        this.AddTypeAlias<JsonNode>();
 942        this.AddTypeAlias<JsonObject>();
 943        this.AddTypeAlias<IDictionary<string, string>>("StringDictionary");
 944        this.AddTypeAlias<IDictionary<string, object>>("ObjectDictionary");
 945        this.AddTypeAlias<Dictionary<string, string>>("StringMap");
 946        this.AddTypeAlias<Dictionary<string, object>>("ObjectMap");
 947    }
 48
 49    /// <summary>
 50    /// Gets the type alias dictionary.
 51    /// </summary>
 1852    public IDictionary<string, Type> AliasTypeDictionary { get; set; }
 53
 54    /// <summary>
 55    /// Registers a well-known type alias.
 56    /// </summary>
 57    public ExpressionOptions RegisterTypeAlias(Type type, string alias)
 58    {
 30759        _aliasTypeDictionary[alias] = type;
 30760        return this;
 61    }
 62}