【问题标题】:Quartz.Net dependency injectionQuartz.Net 依赖注入
【发布时间】: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


【解决方案1】:

找到了,其实可以使用dependencyresolver在quartz类中实现一个类。它适用于我的项目。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-11-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-08
    • 2014-06-12
    相关资源
    最近更新 更多