< Summary

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

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Core/Extensions/BookmarkExtensions.cs

#LineLine coverage
 1using Elsa.Workflows;
 2using Elsa.Workflows.Helpers;
 3using Elsa.Workflows.Models;
 4
 5// ReSharper disable once CheckNamespace
 6namespace Elsa.Extensions;
 7
 8/// <summary>
 9/// Adds extensions to <c>Bookmark</c> and sets thereof.
 10/// </summary>
 11public static class BookmarkExtensions
 12{
 13    /// <param name="bookmarks">The set of bookmarks to filter.</param>
 14    extension(IEnumerable<Bookmark> bookmarks)
 15    {
 16        /// <summary>
 17        /// Filters the specified set of bookmarks by the specified activity type.
 18        /// </summary>
 19        /// <typeparam name="T">The activity type to filter by.</typeparam>
 20        /// <returns>The filtered set of bookmarks.</returns>
 21        public IEnumerable<Bookmark> Filter<T>() where T : IActivity
 22        {
 023            var bookmarkName = ActivityTypeNameHelper.GenerateTypeName<T>();
 024            return bookmarks.Filter(bookmarkName);
 25        }
 26
 27        public IEnumerable<Bookmark> Filter(string name)
 28        {
 374429            return bookmarks.Where(x => x.Name == name);
 30        }
 31    }
 32
 33    /// <summary>
 34    /// Returns the Data property of the bookmark as a strongly-typed object.
 35    /// </summary>
 36    /// <param name="bookmark">The bookmark.</param>
 37    /// <typeparam name="T">The type of the Data property.</typeparam>
 38    /// <returns>The Data property of the bookmark as a strongly-typed object.</returns>
 2339    public static T GetPayload<T>(this Bookmark bookmark) => (T)bookmark.Payload!;
 40}