c# - Instance of a class in Create method of JobBuilder in quartz.net -
the default create method of jobbuilder
ijobdetail paymentjob = jobbuilder.create<hello>().withidentity(jobname, groupname).build();
i checked overloads there no overload in can have instance of class inside. create method. this
ijobdetail paymentjob = jobbuilder.create<new hello()>().withidentity(jobname, groupname).build();
but gives error
operator < cannot applied 'method group' or 'hello'
the reason need is:
public abstract class hello:ijob { public abstract void execute(ijobexecutioncontext context); } public hello1: hello { public void execute(ijobexecutioncontext context) { //implementation } } public hello2: hello { public void execute(ijobexecutioncontext context) { //implementation } } public static hellofactory { public hello gethellotype(helloenum enum) { hello job = new hello(); switch(enum) { case helloenum.type1: job = new hello1(); case helloenum.type2: job = new hello2(); } } }
just change hellofactory return type object instead of hello object:
public static class hellofactory { public type gethellotype(helloenum theenum) { type type; switch (theenum) { case helloenum.type1: type = typeof(hello1); break; case helloenum.type2: job = typeof(hello2); break; } } }
alternatively, implement own jobfactory. here's exmaple on how implement one: http://jayvilalta.com/blog/2012/07/23/creating-a-custom-quartz-net-jobfactory/
Comments
Post a Comment