Custom JobActivator

Hi
I know that Hangfire.JobActivator allow dynamic object creation. It accepts Type as parameter.
However, I would like to implement class factory that use classKey string as parameter and retrieve its fully qualified assembly and type name from xml file.
All of the job object must implement IMyJob interface, and BackgroundJob.Enqueue( x=> x.Execute(parameter); )

Implemented actual job classes are not added into project reference. Instead via “dynamic dll”.

Question

  1. How to implement this ?
  2. If Hangfire doesn’t support this natively, I was thinking to have my own classFactory, create the object and get the GetType() to pass to BackgroundJob.Enqueue(). The job dll will be located in same folder with Hangfire. Does this design compatible?
  3. If answer to question2 is yes, do you think it is working fine for RecurringJob as well?

Please advice. Thank you

I just do a prototype, with below

ProjectA

public interface IJob
{
     void Execute();
}

ProjectB (Actual Job Code)

public class JobA : IJob
{
    public void Execute()
    {
          // Do something
    }
}

ConsoleApp1
Reference: Only ProjectA added

static void Main(string[] args)
{
      // Hangfire start, configuration and etc

     var obj = (IJob)System.Activator.CreateInstance(System.Type.GetType("JobA full qualified assembly name"));

     BackgroundJob.Enqueue( () => obj.Execute() );
     RecurringJob.AddOrUpdate( () => obj.Execute(), Cron.Daily(0, 1));
}

When I check table Hangfire.Hash, found that Hash.Value = “Type”:“ProjectA.IJob, xxxxxxx” instead of ProjectB.JobA.

I double checked hangfire source code, Job.FromExpression() actually referring to callExpression.Method.DeclaringType, which always return the type where the method is declared.

It cause JobActivator unable to instantiate ProjectA.IJob. I tried to use ReflectedType, it return same type.
How to solve this problem?

please advice. thank you