private void ValidateJsonOptions(RecurringJobJsonOptions option) { if (option == null) throw new ArgumentNullException(nameof(option)); if (string.IsNullOrWhiteSpace(option.JobName)) { throw new Exception($"The json token 'job-name' is null, empty, or consists only of white-space."); } if (!option.JobType.GetTypeInfo().ImplementedInterfaces.Contains(typeof(IRecurringJob))) { throw new Exception($"job-type: {option.JobType} must impl the interface {typeof(IRecurringJob)}."); } }
private RecurringJobInfo Convert(RecurringJobJsonOptions option) { ValidateJsonOptions(option); return new RecurringJobInfo { RecurringJobId = option.JobName, #if NET45 Method = option.JobType.GetMethod(nameof(IRecurringJob.Execute)), #else Method = option.JobType.GetTypeInfo().GetDeclaredMethod(nameof(IRecurringJob.Execute)), #endif Cron = option.Cron, Queue = option.Queue ?? EnqueuedState.DefaultQueue, TimeZone = option.TimeZone ?? TimeZoneInfo.Utc, ExtendedData = option.ExtendedData, Enable = option.Enable ?? true }; }