/// <summary> /// Returns a day info if the rule applies /// </summary> /// <param name="date"></param> /// <returns>'null' in case the rule can't apply</returns> public DayInfo GetDayInfo(DateTime date) { if (YearMatchers.Any(_ => _.Match(date)) && MonthMatchers.Any(_ => _.Match(date)) && DayOfMonthMatchers.Any(_ => _.Match(date)) && DayOfWeekMatchers.Any(_ => _.Match(date))) { return(new DayInfo(Description, WorkingPeriods)); } return(null); }
public bool TryGetDayInfo(DateTime date, out DayInfo dayInfo) { dayInfo = default; if (YearMatchers.Any(_ => _.Match(date)) && MonthMatchers.Any(_ => _.Match(date)) && DayOfMonthMatchers.Any(_ => _.Match(date)) && DayOfWeekMatchers.Any(_ => _.Match(date))) { dayInfo = new DayInfo(Description, WorkingPeriods); } return(dayInfo is not null); }