Add Usings

This commit is contained in:
Sergey Chebotar 2023-03-28 10:03:19 +03:00
parent de2f7f43ec
commit 2280b49ae1
3 changed files with 36 additions and 40 deletions

View File

@ -1,13 +1,10 @@
using ExcelDna.Integration; namespace RhSolutions.AddIn;
namespace RhSolutions.AddIn public static class ResetBarFunction
{ {
public static class ResetBarFunction [ExcelFunction]
public static void _ResetStatusBar()
{ {
[ExcelFunction] RhSolutionsAddIn.Excel.StatusBar = false;
public static void _ResetStatusBar()
{
RhSolutionsAddIn.Excel.StatusBar = false;
}
} }
} }

View File

@ -1,43 +1,37 @@
using ExcelDna.Integration; using ExcelDna.IntelliSense;
using ExcelDna.IntelliSense;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Office.Interop.Excel;
using RhSolutions.Services;
using System;
using System.Net; using System.Net;
namespace RhSolutions.AddIn namespace RhSolutions.AddIn;
public sealed class RhSolutionsAddIn : IExcelAddIn
{ {
public sealed class RhSolutionsAddIn : IExcelAddIn public static Application Excel { get; private set; }
public static ServiceProvider ServiceProvider { get; set; }
public static IAddInConfiguration Configuration { get; set; }
public void AutoOpen()
{ {
public static Application Excel { get; private set; } IServiceCollection Services = new ServiceCollection();
public static ServiceProvider ServiceProvider { get; set; }
public static IAddInConfiguration Configuration { get; set; }
public void AutoOpen() Services.AddHttpClient()
{ .AddSingleton<IDatabaseClient, RhDatabaseClient>()
IServiceCollection Services = new ServiceCollection(); .AddSingleton<IAddInConfiguration, AddInConfiguration>()
.AddSingleton((Application)ExcelDnaUtil.Application);
Services.AddHttpClient() ServiceProvider = Services.BuildServiceProvider();
.AddSingleton<IDatabaseClient, RhDatabaseClient>() Configuration = ServiceProvider.GetService<IAddInConfiguration>();
.AddSingleton<IAddInConfiguration, AddInConfiguration>() Excel = ServiceProvider.GetService<Application>();
.AddSingleton((Application)ExcelDnaUtil.Application);
ServiceProvider = Services.BuildServiceProvider(); IntelliSenseServer.Install();
Configuration = ServiceProvider.GetService<IAddInConfiguration>(); EventsUtil.Initialize();
Excel = ServiceProvider.GetService<Application>();
IntelliSenseServer.Install(); ServicePointManager.SecurityProtocol =
EventsUtil.Initialize(); SecurityProtocolType.Tls12;
}
ServicePointManager.SecurityProtocol = public void AutoClose()
SecurityProtocolType.Tls12; {
} IntelliSenseServer.Uninstall();
EventsUtil.Uninitialize();
public void AutoClose()
{
IntelliSenseServer.Uninstall();
EventsUtil.Uninitialize();
}
} }
} }

View File

@ -0,0 +1,5 @@
global using ExcelDna.Integration;
global using Microsoft.Extensions.DependencyInjection;
global using Microsoft.Office.Interop.Excel;
global using RhSolutions.Services;
global using System;