< 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{
 314    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>
 319    public ExpressionOptions()
 20    {
 321        AliasTypeDictionary = new ReadOnlyDictionary<string, Type>(_aliasTypeDictionary);
 22
 323        this.AddTypeAlias<short>("Int16");
 324        this.AddTypeAlias<int>("Int32");
 325        this.AddTypeAlias<long>("Int64");
 326        this.AddTypeAlias<long>("Long");
 327        this.AddTypeAlias<float>("Single");
 328        this.AddTypeAlias<object>("Object");
 329        this.AddTypeAlias<string>("String");
 330        this.AddTypeAlias<bool>("Boolean");
 331        this.AddTypeAlias<decimal>("Decimal");
 332        this.AddTypeAlias<double>("Double");
 333        this.AddTypeAlias<byte[]>("ByteArray");
 334        this.AddTypeAlias<Guid>();
 335        this.AddTypeAlias<DateTime>();
 336        this.AddTypeAlias<DateTimeOffset>();
 337        this.AddTypeAlias<TimeSpan>();
 338        this.AddTypeAlias<Stream>();
 339        this.AddTypeAlias<ExpandoObject>("JSON");
 340        this.AddTypeAlias<JsonElement>();
 341        this.AddTypeAlias<JsonNode>();
 342        this.AddTypeAlias<JsonObject>();
 343        this.AddTypeAlias<IDictionary<string, string>>("StringDictionary");
 344        this.AddTypeAlias<IDictionary<string, object>>("ObjectDictionary");
 345        this.AddTypeAlias<Dictionary<string, string>>("StringMap");
 346        this.AddTypeAlias<Dictionary<string, object>>("ObjectMap");
 347    }
 48
 49    /// <summary>
 50    /// Gets the type alias dictionary.
 51    /// </summary>
 652    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    {
 8559        _aliasTypeDictionary[alias] = type;
 8560        return this;
 61    }
 62}