From 56112eae51349ce88cc4ec0c34f6269cc821f0d0 Mon Sep 17 00:00:00 2001 From: Serghei Cebotari Date: Sun, 21 Jan 2024 14:51:38 +0300 Subject: [PATCH] Refactoring Excel application field --- RhSolutions.AddIn/AddIn/RhSolutionsAddIn.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/RhSolutions.AddIn/AddIn/RhSolutionsAddIn.cs b/RhSolutions.AddIn/AddIn/RhSolutionsAddIn.cs index cd62e22..f664491 100644 --- a/RhSolutions.AddIn/AddIn/RhSolutionsAddIn.cs +++ b/RhSolutions.AddIn/AddIn/RhSolutionsAddIn.cs @@ -4,7 +4,7 @@ namespace RhSolutions.AddIn; public sealed class RhSolutionsAddIn : IExcelAddIn { - public static Application Excel { get; private set; } + public static readonly Application Excel = (Application)ExcelDnaUtil.Application; public static ServiceProvider ServiceProvider { get; private set; } public static IAddInConfiguration Configuration { get; private set; } @@ -14,7 +14,6 @@ public sealed class RhSolutionsAddIn : IExcelAddIn Services.AddHttpClient() .AddMemoryCache() - .AddSingleton((Application)ExcelDnaUtil.Application) .AddSingleton() .AddSingleton() .AddSingleton() @@ -44,7 +43,6 @@ public sealed class RhSolutionsAddIn : IExcelAddIn ServiceProvider = Services.BuildServiceProvider(); Configuration = ServiceProvider.GetService(); - Excel = ServiceProvider.GetService(); EventsUtil.Initialize();