using FluentScheduler;
using Microsoft.Extensions.DependencyInjection;
using Performance.Services;
using System;
using System.Linq;
using System.Reflection;

namespace Performance.Api.Configurations
{
    public static class FluentSchedulerConfig
    {
        public static void AddFluentSchedulerConfiguration(this IServiceCollection services)
        {
            if (services == null) throw new ArgumentNullException(nameof(services));

            ServiceLocator.Instance = services.BuildServiceProvider();
            JobManager.Initialize(new JobRegistry());

            ////扫描当前程序集中实现了Registry的类
            //var registrys = Assembly.GetExecutingAssembly().GetTypes()
            //                       .Where(t => !t.IsInterface && !t.IsSealed && !t.IsAbstract && typeof(Registry).IsAssignableFrom(t))
            //                       .Select(s => s.Assembly.CreateInstance(s.FullName) as Registry)?.ToArray();

            //// 注册同步服务
            //JobManager.Initialize(registrys);
        }
    }
}
