using Cleanuparr.Infrastructure.Models; namespace Cleanuparr.Infrastructure.Utilities; /// /// Provides predefined valid scheduling options for different time units /// public static class ScheduleOptions { /// /// Valid second values (only 30 seconds is allowed) /// public static readonly int[] ValidSecondValues = { 30 }; /// /// Valid minute values (values that divide evenly into 60) /// public static readonly int[] ValidMinuteValues = { 1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30 }; /// /// Valid hour values (values that divide evenly into 24) /// public static readonly int[] ValidHourValues = { 1, 2, 3, 4, 6, 8, 12 }; /// /// Get valid scheduling values for a given time unit /// /// The time unit /// Array of valid values for the given unit public static int[] GetValidValues(ScheduleUnit unit) { return unit switch { ScheduleUnit.Seconds => ValidSecondValues, ScheduleUnit.Minutes => ValidMinuteValues, ScheduleUnit.Hours => ValidHourValues, _ => throw new ArgumentOutOfRangeException(nameof(unit), unit, "Unknown schedule unit") }; } /// /// Checks if a value is valid for a given time unit /// /// The time unit /// The value to check /// True if the value is valid for the given unit, false otherwise public static bool IsValidValue(ScheduleUnit unit, int value) { return GetValidValues(unit).Contains(value); } }