using FreeRedis;
using Learn.Archives.Core.Model;
using Learn.Archives.Core.Model.Interface;
using Microsoft.Extensions.DependencyModel;
using Microsoft.IdentityModel.Tokens;
using SqlSugar;
using SqlSugar.IOC;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Reflection.PortableExecutable;
using System.Runtime.Loader;
using System.Security.Cryptography;
using System.Text;
using System.Text.Json;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using UserCenter.Model.Interface;
using MiniExcelLibs;
using MiniExcelLibs.OpenXml;
using Microsoft.AspNetCore.Http;
using Learn.Archives.Core.Model.Dto;
namespace Learn.Archives.Core.Common
{
///
/// 程序 公共变量
///
public static class AppCommon
{
///
/// 应用有效程序集
///
public static readonly IEnumerable Assemblies;
///
/// 主库数据库表类型
///
public static readonly IEnumerable DbMatserType;
public static readonly IEnumerable UserCenterType;
public static readonly Dictionary EnumType;
static AppCommon()
{
try
{
var projectName = Assembly.GetExecutingAssembly().GetName().Name;
Assemblies = ExpandFunction.GetAssemblies();
var assembliesType = Assemblies
//.Where(s => s.FullName.Contains(projectName))
.SelectMany(s => s.ExportedTypes.Where(u => !u.IsInterface && !u.IsAbstract && u.IsClass && u.IsDefined(typeof(SugarTable), false)));
DbMatserType = assembliesType
.Where(u => u.GetInterfaces().Contains(typeof(IDB)));
UserCenterType = assembliesType
.Where(u => u.FullName.Contains("UserCenter"));
EnumType = Assemblies
.Where(s => s.FullName.Contains("Model")|| s.FullName.Contains("Core"))
.SelectMany(s => s.GetTypes().Where(x => x.IsEnum))
.DistinctBy(s=>s.Name)
.ToDictionary(s => s.Name, s => s);
}
catch
{
throw;
}
}
///
/// 程序配置
///
public static AppConfig Config = new AppConfig();
///
/// ServiceProvider
///
public static IServiceProvider? Services;
}
///
/// 拓展函数
///
public static class ExpandFunction
{
const string SheetName = "Sheet1";
public static byte[] ExportExcel(this IEnumerable