| | | 1 | | using Elsa.Scheduling.ScheduledTasks; |
| | | 2 | | using JetBrains.Annotations; |
| | | 3 | | using Microsoft.Extensions.DependencyInjection; |
| | | 4 | | |
| | | 5 | | namespace Elsa.Scheduling.Schedules; |
| | | 6 | | |
| | | 7 | | /// <summary> |
| | | 8 | | /// A recurring schedule. |
| | | 9 | | /// </summary> |
| | | 10 | | [PublicAPI] |
| | | 11 | | public class RecurringSchedule : ISchedule |
| | | 12 | | { |
| | | 13 | | /// <summary> |
| | | 14 | | /// Initializes a new instance of the <see cref="RecurringSchedule"/> class. |
| | | 15 | | /// </summary> |
| | | 16 | | /// <param name="startAt">The time at which the first occurrence should occur.</param> |
| | | 17 | | /// <param name="interval">The interval between occurrences.</param> |
| | 2 | 18 | | public RecurringSchedule(DateTimeOffset startAt, TimeSpan interval) |
| | | 19 | | { |
| | 2 | 20 | | StartAt = startAt; |
| | 2 | 21 | | Interval = interval; |
| | 2 | 22 | | } |
| | | 23 | | |
| | | 24 | | /// <summary> |
| | | 25 | | /// The time at which the first occurrence should occur. |
| | | 26 | | /// </summary> |
| | 4 | 27 | | public DateTimeOffset StartAt { get; init; } |
| | | 28 | | |
| | | 29 | | /// <summary> |
| | | 30 | | /// The interval between occurrences. |
| | | 31 | | /// </summary> |
| | 4 | 32 | | public TimeSpan Interval { get; init; } |
| | | 33 | | |
| | | 34 | | /// <inheritdoc /> |
| | | 35 | | public IScheduledTask Schedule(ScheduleContext context) => |
| | 2 | 36 | | ActivatorUtilities.CreateInstance<ScheduledRecurringTask>(context.ServiceProvider, context.Task, StartAt, Interv |
| | | 37 | | } |