.net Net依赖注入
我在这里看到了很多解决方案,但它们已经过时了。有新的方法吗?是关于Ijob工厂的事.net Net依赖注入,.net,dependency-injection,quartz.net,.net,Dependency Injection,Quartz.net,我在这里看到了很多解决方案,但它们已经过时了。有新的方法吗?是关于Ijob工厂的事 public class JobBase : IJob { private readonly ILogger _logger; public JobBase(ILogger logger) { _logger = logger; } public void Initialize() { // Create fake httpconte
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)
{
}
}
找到它后,您实际上可以使用dependencyresolver在quartz类中实现一个类。它对我的项目起了作用。不久前我写了一篇关于它的帖子。你没有提到你发现的东西过时了,但这里有一个链接,以防有用:我指的是代码公共类NinjectJobFactory:IJobFactory{private readonly IResolutionRoot resolutionRoot;public NinjectJobFactoryResolutionRoot resolutionRoot{this.resolutionRoot=resolutionRoot;}public IJob NewJobTriggerFiredBundle bundle,isScheduler调度程序{返回IJobthis.resolutionRoot.Getbundle.jobdail.JobType;}public void返回jobijob作业{this.resolutionRoot.Releasejob;}代码、获取/发布不再存在