using dodohold.core;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.OpenApi.Models;
using Swashbuckle.AspNetCore.SwaggerGen;

namespace molilian.core
{
    public static class CustomToken
    {
        public static IServiceCollection Init(this IServiceCollection services)
        {
            //int minWorkerThreads = 128;  // 工作线程数的建议设置
            //int minIOCompletionThreads = 512;  // I/O 完成端口线程数的建议设置
            //ThreadPool.SetMinThreads(minWorkerThreads, minIOCompletionThreads);


            //int newMaxWorker = 65535;  // 新的最大工作线程数
            //int newMaxIOC = 2000;      // 新的最大I/O完成端口线程数
            //ThreadPool.SetMaxThreads(newMaxWorker, newMaxIOC);

            //注入验证 provider
            MyAuthorizationFactory.Register(new AdminProvider());
            MyAuthorizationFactory.Register(new AppProvider());
            MyAuthorizationFactory.Register(new APIProvider(), true);


            //Configuration = configuration;

            //AppUtility.Configuration = Configuration;
            //var appSettings = Configuration.GetSection("AppSettings");
            //appSettings.Bind(AppUtility.AppSettings);

            //初始化Redis
            RedisUtility.Init();

            //定期任务
            TimerScheduler.TaskContainers taskContainers = new();
            TimerScheduler timerScheduler = new TimerScheduler(taskContainers);
            timerScheduler.Start();

            //services.AddMvc(option =>
            //{
            //    option.Filters.Add(typeof(MyAuthorizationFactory.MyActionFilter));
            //    option.Filters.Add(typeof(ResponseExceptionFilterAttribute));
            //});
            return services;
        }

    }
}
