< Summary

Information
Class: Elsa.Extensions.StoredBookmarkExtensions
Assembly: Elsa.Workflows.Runtime
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Runtime/Extensions/StoredBookmarkExtensions.cs
Line coverage
50%
Covered lines: 2
Uncovered lines: 2
Coverable lines: 4
Total lines: 37
Line coverage: 50%
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
GetPayload(...)100%11100%
Filter(...)100%210%
Filter(...)100%11100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Runtime/Extensions/StoredBookmarkExtensions.cs

#LineLine coverage
 1using Elsa.Workflows;
 2using Elsa.Workflows.Helpers;
 3using Elsa.Workflows.Runtime.Entities;
 4
 5// ReSharper disable once CheckNamespace
 6namespace Elsa.Extensions;
 7
 8/// <summary>
 9/// Adds extensions to <see cref="StoredBookmark"/>.
 10/// </summary>
 11public static class StoredBookmarkExtensions
 12{
 13    /// <summary>
 14    /// Returns the Data property of the stored bookmark as a strongly-typed object.
 15    /// </summary>
 16    /// <param name="storedBookmark">The stored bookmark.</param>
 17    /// <typeparam name="T">The type of the Data property.</typeparam>
 18    /// <returns>The Data property of the stored bookmark as a strongly-typed object.</returns>
 219    public static T GetPayload<T>(this StoredBookmark storedBookmark) => (T)storedBookmark.Payload!;
 20
 21    /// <summary>
 22    /// Filters the specified set of stored bookmarks by the specified activity type.
 23    /// </summary>
 24    /// <param name="bookmarks">The set of stored bookmarks to filter.</param>
 25    /// <typeparam name="T">The activity type to filter by.</typeparam>
 26    /// <returns>The filtered set of stored bookmarks.</returns>
 27    public static IEnumerable<StoredBookmark> Filter<T>(this IEnumerable<StoredBookmark> bookmarks) where T : IActivity
 28    {
 029        var bookmarkName = ActivityTypeNameHelper.GenerateTypeName<T>();
 030        return bookmarks.Filter(bookmarkName);
 31    }
 32
 33    public static IEnumerable<StoredBookmark> Filter(this IEnumerable<StoredBookmark> bookmarks, string name)
 34    {
 40435        return bookmarks.Where(x => x.Name == name);
 36    }
 37}