RhSolutions-AddIn/RhSolutions.AddIn/AddIn/RhSolutionsAddIn.cs
2023-03-27 07:12:04 +03:00

39 lines
1.1 KiB
C#

using ExcelDna.Integration;
using ExcelDna.IntelliSense;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Office.Interop.Excel;
using RhSolutions.Services;
using System.Net;
namespace RhSolutions.AddIn
{
public class RhSolutionsAddIn : IExcelAddIn
{
public static Application Excel { get; private set; }
public static ServiceProvider ServiceProvider { get; set; }
public void AutoOpen()
{
IServiceCollection Services = new ServiceCollection();
Services.AddHttpClient();
ServiceProvider = Services.BuildServiceProvider();
Excel = (Application)ExcelDnaUtil.Application;
IntelliSenseServer.Install();
RegistryUtil.Initialize();
EventsUtil.Initialize();
ServicePointManager.SecurityProtocol =
SecurityProtocolType.Tls12;
}
public void AutoClose()
{
IntelliSenseServer.Uninstall();
RegistryUtil.Uninitialize();
EventsUtil.Uninitialize();
//HttpClient.Dispose();
}
}
}