Quartz.Net dependency injection

548 Views Asked by At

I see a lot of solutions here but they area already outdated. Is there a new approach? It's something about the 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)
    {

    }
}
1

There are 1 best solutions below

0
On BEST ANSWER

Found it, you can actually use dependencyresolver to implement a class in the quartz class. It worked for my project.