Services/JobService/CornJobRunnerFactory.cs

(完整代码) 818B

using JobService.CronJob;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace JobService
{
    public class CornJobRunnerFactory
    {
        static List<Action> Jobs = new List<Action>();
        public static void RegisterAllJobs()
        {
            foreach (var childclass in typeof(CronJobBase).Assembly.GetTypes().Where(x => x.BaseType == typeof(CronJobBase)))
            {
                Action job = childclass.GetMethod(nameof(CronJobBase.RunCornJob)).CreateDelegate(typeof(Action), Activator.CreateInstance(childclass)) as Action;
                Jobs.Add(job);
            }
        }
        public static void RunAllJobs()
        {
            foreach (var job in Jobs)
            {
                job();
            }
        }
    }
}

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。