以下是在将作业添加到调度程序之前将数据放入x { {s1. a1}. {s2. a2}. ... {sn. an} }
的示例:
JobDataMap
从IJobDetail job = JobBuilder.Create<DumbJob>()
.UsingJobData("jobSays", "Hello World!")
.UsingJobData("myFloatValue", 3.141f)
.Build();
获取值:
JobDataMap
但它只适用于原始类型。因此,我无法在工作执行期间找到转移public class DumbJob : IJob
{
public void Execute(JobExecutionContext context)
{
JobDataMap dataMap = context.JobDetail.JobDataMap;
string jobSays = dataMap.GetString("jobSays");
float myFloatValue = dataMap.GetFloat("myFloatValue");
}
}
的方法。我怎么能这样做?
答案 0 :(得分:0)
尝试
IJobDetail job = JobBuilder.Create<DumbJob>()
.UsingJobData("someKey", someObjectOfTypeT)
.Build();
TypeT someValue = <TypeT>dataMap.Get("someKey");