diff --git a/SmartCmdArgs/SmartCmdArgs.Shared/CmdArgsPackage.cs b/SmartCmdArgs/SmartCmdArgs.Shared/CmdArgsPackage.cs index e43d38c3..630a9028 100644 --- a/SmartCmdArgs/SmartCmdArgs.Shared/CmdArgsPackage.cs +++ b/SmartCmdArgs/SmartCmdArgs.Shared/CmdArgsPackage.cs @@ -167,7 +167,7 @@ private ServiceProvider ConfigureServices() var services = new ServiceCollection(); services.AddSingleton(); - services.AddSingleton(x => GetDialogPage()); + services.AddLazySingleton(x => GetDialogPage()); services.AddLazySingleton(); services.AddLazySingleton(); services.AddLazySingleton(); diff --git a/SmartCmdArgs/SmartCmdArgs.Shared/Services/OptionsSettingsService.cs b/SmartCmdArgs/SmartCmdArgs.Shared/Services/OptionsSettingsService.cs index de0ab2b8..e3fe3a08 100644 --- a/SmartCmdArgs/SmartCmdArgs.Shared/Services/OptionsSettingsService.cs +++ b/SmartCmdArgs/SmartCmdArgs.Shared/Services/OptionsSettingsService.cs @@ -38,19 +38,19 @@ internal class OptionsSettingsService : PropertyChangedBase, IOptionsSettingsSer { private readonly IVisualStudioHelperService _vsHelperService; private readonly SettingsViewModel settingsViewModel; - private readonly CmdArgsOptionPage optionPage; + private readonly Lazy lazyOptionsPage; public OptionsSettingsService( IVisualStudioHelperService vsHelperService, SettingsViewModel settingsViewModel, - CmdArgsOptionPage optionPage) + Lazy lazyOptionsPage) { _vsHelperService = vsHelperService; this.settingsViewModel = settingsViewModel; - this.optionPage = optionPage; + this.lazyOptionsPage = lazyOptionsPage; } - private CmdArgsOptionPage OptionsPage => optionPage; + private CmdArgsOptionPage OptionsPage => lazyOptionsPage.Value; // Settings (possibly with options default) public bool SaveSettingsToJson => settingsViewModel.SaveSettingsToJson; diff --git a/SmartCmdArgs/SmartCmdArgs.Shared/ViewModel/SettingsViewModel.cs b/SmartCmdArgs/SmartCmdArgs.Shared/ViewModel/SettingsViewModel.cs index 2af2b54b..e6341717 100644 --- a/SmartCmdArgs/SmartCmdArgs.Shared/ViewModel/SettingsViewModel.cs +++ b/SmartCmdArgs/SmartCmdArgs.Shared/ViewModel/SettingsViewModel.cs @@ -8,7 +8,7 @@ namespace SmartCmdArgs.ViewModel { public class SettingsViewModel : PropertyChangedBase { - private readonly CmdArgsOptionPage optionPage; + private readonly Lazy optionPage; private readonly Lazy lifeCycleService; private bool _saveSettingsToJson; private bool? _manageCommandLineArgs; @@ -83,13 +83,13 @@ public bool? MacroEvaluationEnabled public RelayCommand DisableExtensionCommand { get; } - public CmdArgsOptionPage Options => optionPage; + public CmdArgsOptionPage Options => optionPage.Value; public ILifeCycleService LifeCycle => lifeCycleService.Value; public RelayCommand OpenOptionsCommand { get; } public SettingsViewModel( - CmdArgsOptionPage optionPage, + Lazy optionPage, Lazy lifeCycleService) { this.optionPage = optionPage;