fix(schedules): protect against null schedules
This commit is contained in:
parent
07eb12414a
commit
b32ca7582c
1 changed files with 10 additions and 1 deletions
|
@ -49,6 +49,15 @@ public partial class ApplySchedules : OperationBase
|
||||||
return input.Select(this.Apply);
|
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>(
|
public ApplySchedules WithGetSchedules<TType>(
|
||||||
Func<Entity, IEnumerable<TType>?> value)
|
Func<Entity, IEnumerable<TType>?> value)
|
||||||
where TType : ISchedule
|
where TType : ISchedule
|
||||||
|
@ -74,7 +83,7 @@ public partial class ApplySchedules : OperationBase
|
||||||
// Otherwise, apply the schedules to this entity.
|
// Otherwise, apply the schedules to this entity.
|
||||||
foreach (ISchedule schedule in schedules)
|
foreach (ISchedule schedule in schedules)
|
||||||
{
|
{
|
||||||
if (!schedule.CanApply(entity))
|
if (schedule == null! || !schedule.CanApply(entity))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue