Add Application Singleton
This commit is contained in:
parent
15dd27fb68
commit
68512dba2b
@ -8,7 +8,7 @@ using System.Net;
|
||||
|
||||
namespace RhSolutions.AddIn
|
||||
{
|
||||
public class RhSolutionsAddIn : IExcelAddIn
|
||||
public sealed class RhSolutionsAddIn : IExcelAddIn
|
||||
{
|
||||
public static Application Excel { get; private set; }
|
||||
public static ServiceProvider ServiceProvider { get; set; }
|
||||
@ -17,15 +17,16 @@ namespace RhSolutions.AddIn
|
||||
public void AutoOpen()
|
||||
{
|
||||
IServiceCollection Services = new ServiceCollection();
|
||||
Excel = (Application)ExcelDnaUtil.Application;
|
||||
|
||||
Services.AddHttpClient()
|
||||
.AddSingleton<IDatabaseClient, RhDatabaseClient>()
|
||||
.AddSingleton<IAddInConfiguration, AddInConfiguration>();
|
||||
.AddSingleton<IAddInConfiguration, AddInConfiguration>()
|
||||
.AddSingleton(ExcelDnaUtil.Application);
|
||||
|
||||
ServiceProvider = Services.BuildServiceProvider();
|
||||
Configuration = ServiceProvider.GetService<IAddInConfiguration>();
|
||||
|
||||
Excel = ServiceProvider.GetService<Application>();
|
||||
|
||||
IntelliSenseServer.Install();
|
||||
EventsUtil.Initialize();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user