【发布时间】:2014-11-20 08:59:06
【问题描述】:
我在这里看到了很多解决方案,但它们已经过时了。有新方法吗?这是关于 Ijobfactory 的事情。
public class JobBase : IJob
{
private readonly ILogger _logger;
public JobBase(ILogger logger)
{
_logger = logger;
}
public void Initialize()
{
// Create fake httpcontext
HttpContext.Current = new HttpContext(
new HttpRequest(null, "[localhost]", ""),
new HttpResponse(new StreamWriter(new MemoryStream())));
}
public virtual void Execute(IJobExecutionContext context)
{
}
}
【问题讨论】:
-
我不久前写了一篇关于它的帖子。您没有提及您发现的内容已经过时,但这里有一个链接,以防它有用:jayvilalta.com/blog/2012/07/23/…
-
我指的是
codepublic 类 NinjectJobFactory : IJobFactory { private readonly IResolutionRoot resolutionRoot;公共 NinjectJobFactory(IResolutionRoot resolutionRoot) { this.resolutionRoot = resolutionRoot; } public IJob NewJob(TriggerFiredBundle bundle, IScheduler scheduler) { return (IJob)this.resolutionRoot.Get(bundle.JobDetail.JobType); } 公共无效 ReturnJob(IJob 工作) { this.resolutionRoot.Release(job); } }code,Get/Release 不存在了
标签: .net dependency-injection quartz.net