public IJob NewJob(TriggerFiredBundle bundle, IScheduler scheduler) { var jobDetail = bundle.JobDetail; if (jobDetail == null) { throw new SchedulerException("JobDetail was null"); } var type = jobDetail.JobType; if (type == typeof(ScheduledMessageJob)) { try { var job = new ScheduledMessageJob(_bus); var jobData = new JobDataMap(); jobData.PutAll(scheduler.Context); jobData.PutAll(bundle.JobDetail.JobDataMap); jobData.PutAll(bundle.Trigger.JobDataMap); jobData.Put("PayloadMessageHeadersAsJson", CreatePayloadHeaderString(bundle)); SetObjectProperties(job, jobData); return(job); } catch (Exception ex) { throw new SchedulerException($"Problem instantiating class '{TypeMetadataCache.GetShortName(bundle.JobDetail.JobType)}'", ex); } } return(_jobFactory.NewJob(bundle, scheduler)); }
static void SetObjectProperties(ScheduledMessageJob job, JobDataMap jobData) { foreach (var key in jobData.Keys) { if (TypeCache <ScheduledMessageJob> .ReadWritePropertyCache.TryGetProperty(key, out ReadWriteProperty <ScheduledMessageJob> property)) { var value = jobData[key]; if (property.Property.PropertyType == typeof(Uri)) { value = new Uri(value.ToString()); } property.Set(job, value); } } }