| | | 1 | | using Elsa.Workflows.Models; |
| | | 2 | | using Elsa.Workflows.Runtime.Entities; |
| | | 3 | | |
| | | 4 | | namespace Elsa.Workflows.Runtime; |
| | | 5 | | |
| | | 6 | | /// <summary> |
| | | 7 | | /// Contains extension methods for <see cref="Bookmark"/>. |
| | | 8 | | /// </summary> |
| | | 9 | | public static class BookmarkExtensions |
| | | 10 | | { |
| | | 11 | | /// <summary> |
| | | 12 | | /// Converts a <see cref="Bookmark"/> to a <see cref="BookmarkInfo"/>. |
| | | 13 | | /// </summary> |
| | 0 | 14 | | public static BookmarkInfo ToBookmarkInfo(this Bookmark source) => new() |
| | 0 | 15 | | { |
| | 0 | 16 | | Hash = source.Hash, |
| | 0 | 17 | | Id = source.Id, |
| | 0 | 18 | | Name = source.Name |
| | 0 | 19 | | }; |
| | | 20 | | |
| | | 21 | | /// <summary> |
| | | 22 | | /// Converts a collection of <see cref="Bookmark"/> to a collection of <see cref="BookmarkInfo"/>. |
| | | 23 | | /// </summary> |
| | | 24 | | public static IEnumerable<BookmarkInfo> ToBookmarkInfos(this IEnumerable<Bookmark> source) |
| | | 25 | | { |
| | 0 | 26 | | return source.Select(ToBookmarkInfo); |
| | | 27 | | } |
| | | 28 | | |
| | | 29 | | public static IEnumerable<StoredBookmark> MapBookmarks(this WorkflowExecutionContext workflowExecutionContext, IEnum |
| | | 30 | | { |
| | 0 | 31 | | return bookmarks.Select(workflowExecutionContext.MapBookmark); |
| | | 32 | | } |
| | | 33 | | |
| | | 34 | | public static StoredBookmark MapBookmark(this WorkflowExecutionContext workflowExecutionContext, Bookmark bookmark) |
| | | 35 | | { |
| | 57 | 36 | | return new StoredBookmark |
| | 57 | 37 | | { |
| | 57 | 38 | | Id = bookmark.Id, |
| | 57 | 39 | | Name = bookmark.Name, |
| | 57 | 40 | | Hash = bookmark.Hash, |
| | 57 | 41 | | WorkflowInstanceId = workflowExecutionContext.Id, |
| | 57 | 42 | | CreatedAt = bookmark.CreatedAt, |
| | 57 | 43 | | ActivityInstanceId = bookmark.ActivityInstanceId, |
| | 57 | 44 | | CorrelationId = workflowExecutionContext.CorrelationId, |
| | 57 | 45 | | Payload = bookmark.Payload, |
| | 57 | 46 | | Metadata = bookmark.Metadata |
| | 57 | 47 | | }; |
| | | 48 | | } |
| | | 49 | | } |