fix(schedules): protect against null schedules

This commit is contained in:
D. Moonfire 2023-01-21 12:13:09 -06:00
parent 07eb12414a
commit b32ca7582c

View file

@ -49,6 +49,15 @@ public partial class ApplySchedules : OperationBase
return input.Select(this.Apply);
}
/// <summary>
/// Adds a single schedule into the apply schedules and returns the ApplySchedule
/// class.
/// </summary>
public ApplySchedules WithGetSchedules(Func<Entity, ISchedule> schedule)
{
return this.WithGetSchedules(entity => new[] { schedule(entity) });
}
public ApplySchedules WithGetSchedules<TType>(
Func<Entity, IEnumerable<TType>?> value)
where TType : ISchedule
@ -74,7 +83,7 @@ public partial class ApplySchedules : OperationBase
// Otherwise, apply the schedules to this entity.
foreach (ISchedule schedule in schedules)
{
if (!schedule.CanApply(entity))
if (schedule == null! || !schedule.CanApply(entity))
{
continue;
}