| | | 1 | | using Elsa.Workflows; |
| | | 2 | | using Elsa.Workflows.Helpers; |
| | | 3 | | using Elsa.Workflows.Runtime.Entities; |
| | | 4 | | |
| | | 5 | | // ReSharper disable once CheckNamespace |
| | | 6 | | namespace Elsa.Extensions; |
| | | 7 | | |
| | | 8 | | /// <summary> |
| | | 9 | | /// Adds extensions to <see cref="StoredBookmark"/>. |
| | | 10 | | /// </summary> |
| | | 11 | | public 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> |
| | 2 | 19 | | 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 | | { |
| | 0 | 29 | | var bookmarkName = ActivityTypeNameHelper.GenerateTypeName<T>(); |
| | 0 | 30 | | return bookmarks.Filter(bookmarkName); |
| | | 31 | | } |
| | | 32 | | |
| | | 33 | | public static IEnumerable<StoredBookmark> Filter(this IEnumerable<StoredBookmark> bookmarks, string name) |
| | | 34 | | { |
| | 404 | 35 | | return bookmarks.Where(x => x.Name == name); |
| | | 36 | | } |
| | | 37 | | } |