Пример #1
0
        protected override async System.Threading.Tasks.Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress)
        {
            try {
                await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);

                AsyncPackageHelper.InitializePackage(GetType().Name);

                // can only get a dialog page from a package
                OptionsDialogPage = (IOptionsDialogPage)GetDialogPage(typeof(OptionsDialogPage));

                ((IServiceContainer)this).AddService(typeof(SOptionsDialogPageAccessor), CreateService, true);
                ((IServiceContainer)this).AddService(typeof(SToolWindowProvider), CreateService, true);

                await base.InitializeAsync(cancellationToken, progress);

                _componentModel = GetGlobalService(typeof(SComponentModel)) as IComponentModel;
                Assumes.Present(_componentModel);
                _sessionService = _componentModel.GetService <ISessionService>();
                var settingsServiceFactory = _componentModel?.GetService <ISettingsServiceFactory>();
                _settingsManager = settingsServiceFactory.Create();
                Assumes.Present(_settingsManager);

                await JoinableTaskFactory.RunAsync(VsTaskRunContext.UIThreadNormalPriority, InitializeCommandsAsync);

                Log.Debug($"{nameof(InitializeAsync)} completed");
            }
            catch (Exception ex) {
                Log.Fatal(ex, nameof(InitializeAsync));
            }
        }
Пример #2
0
        protected override async System.Threading.Tasks.Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress)
        {
            _componentModel = await GetServiceAsync(typeof(SComponentModel)) as IComponentModel;

            Assumes.Present(_componentModel);

            await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);

            // can only get a dialog page from a package
            _optionsDialogPage = (IOptionsDialogPage)GetDialogPage(typeof(OptionsDialogPage));
            _settingsManager   = new SettingsManager(_optionsDialogPage);
            ((IServiceContainer)this).AddService(typeof(SSettingsManagerAccessor), CreateService, true);

            AsyncPackageHelper.InitializeLogging(_settingsManager.GetExtensionTraceLevel());
            AsyncPackageHelper.InitializePackage(GetType().Name);
            if (_settingsManager?.DialogPage != null)
            {
                _settingsManager.DialogPage.PropertyChanged += DialogPage_PropertyChanged;
            }

            await base.InitializeAsync(cancellationToken, progress);
        }
Пример #3
0
        // once we don't support VS 2017, we'll be able to use something like...
        // the _lazy.GetValue() method only exists on the v16.0 version of MS.VS.Threading assembly

        //By using this your pain will be legendary, even in hell.
        //private readonly AsyncLazy<IOptionsDialogPage> _lazy = new AsyncLazy<IOptionsDialogPage>(async () => {
        //	var dialogPage = await OptionsDialogPage.GetLiveInstanceAsync();
        //	return dialogPage;
        //}, ThreadHelper.JoinableTaskFactory);

        //By using this your pain will be legendary, even in hell.
        //public async System.Threading.Tasks.Task InitializeAsync() {
        //	DialogPage = await OptionsDialogPage.GetLiveInstanceAsync();
        //}

        public SettingsManager(IOptionsDialogPage dialogPage)
        {
            DialogPage = dialogPage;
            DialogPage.LoadSettingsFromStorage();
        }
Пример #4
0
 public OptionsDialogPageAccessor(IOptionsDialogPage optionsDialogPage)
 {
     _optionsDialogPage = optionsDialogPage;
 }