using System.Net; namespace RhSolutions.AddIn; public sealed class RhSolutionsAddIn : IExcelAddIn { public static Application Excel { get; private set; } public static ServiceProvider ServiceProvider { get; private set; } public static IAddInConfiguration Configuration { get; private set; } public void AutoOpen() { IServiceCollection Services = new ServiceCollection(); Services.AddHttpClient() .AddMemoryCache() .AddSingleton((Application)ExcelDnaUtil.Application) .AddSingleton() .AddSingleton() .AddSingleton() .AddTransient(); Services.AddSingleton(); Services.AddTransient() .AddTransient(s => s.GetService()); Services.AddTransient() .AddTransient(s => s.GetService()); Services.AddTransient() .AddTransient(s => s.GetService()); Services.AddSingleton(); Services.AddTransient() .AddTransient(s => s.GetService()); Services.AddTransient() .AddTransient(s => s.GetService()); Services.AddSingleton(); Services.AddTransient() .AddTransient(s => s.GetService()); Services.AddTransient() .AddTransient(s => s.GetService()); Services.AddTransient(); Services.AddSingleton(); ServiceProvider = Services.BuildServiceProvider(); Configuration = ServiceProvider.GetService(); Excel = ServiceProvider.GetService(); EventsUtil.Initialize(); ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; ServicePointManager.DefaultConnectionLimit = 50; } public void AutoClose() { EventsUtil.Uninitialize(); } }