Application Singleton fix

This commit is contained in:
Sergey Chebotar 2023-03-28 07:55:45 +03:00
parent 6555d6343f
commit 7bb6ce6c5a
2 changed files with 7 additions and 9 deletions

View File

@ -21,7 +21,7 @@ namespace RhSolutions.AddIn
Services.AddHttpClient()
.AddSingleton<IDatabaseClient, RhDatabaseClient>()
.AddSingleton<IAddInConfiguration, AddInConfiguration>()
.AddSingleton(ExcelDnaUtil.Application);
.AddSingleton((Application)ExcelDnaUtil.Application);
ServiceProvider = Services.BuildServiceProvider();
Configuration = ServiceProvider.GetService<IAddInConfiguration>();

View File

@ -7,21 +7,19 @@ namespace RhSolutions.Services
{
internal static class EventsUtil
{
private static readonly Application Excel = RhSolutionsAddIn.Excel;
public static void Initialize()
{
Excel.SheetSelectionChange += RefreshExportButton;
Excel.SheetActivate += RefreshConvertButton;
Excel.WorkbookActivate += RefreshConvertButton;
RhSolutionsAddIn.Excel.SheetSelectionChange += RefreshExportButton;
RhSolutionsAddIn.Excel.SheetActivate += RefreshConvertButton;
RhSolutionsAddIn.Excel.WorkbookActivate += RefreshConvertButton;
RhSolutionsAddIn.Configuration.OnSettingsChange += RefreshSettingTitle;
}
public static void Uninitialize()
{
Excel.SheetSelectionChange -= RefreshExportButton;
Excel.SheetActivate -= RefreshConvertButton;
Excel.WorkbookActivate -= RefreshConvertButton;
RhSolutionsAddIn.Excel.SheetSelectionChange -= RefreshExportButton;
RhSolutionsAddIn.Excel.SheetActivate -= RefreshConvertButton;
RhSolutionsAddIn.Excel.WorkbookActivate -= RefreshConvertButton;
RhSolutionsAddIn.Configuration.OnSettingsChange -= RefreshSettingTitle;
}