public bool TryInstallPackage(
            Workspace workspace,
            DocumentId documentId,
            string source,
            string packageName,
            string versionOpt,
            bool includePrerelease,
            CancellationToken cancellationToken)
        {
            this.AssertIsForeground();

            // The 'workspace == _workspace' line is probably not necessary. However, we include
            // it just to make sure that someone isn't trying to install a package into a workspace
            // other than the VisualStudioWorkspace.
            if (workspace == _workspace && _workspace != null && IsEnabled)
            {
                var projectId  = documentId.ProjectId;
                var dte        = (EnvDTE.DTE)_serviceProvider.GetService(typeof(SDTE));
                var dteProject = _workspace.TryGetDTEProject(projectId);
                if (dteProject != null)
                {
                    var description = string.Format(ServicesVSResources.Install_0, packageName);

                    var undoManager = _editorAdaptersFactoryService.TryGetUndoManager(
                        workspace, documentId, cancellationToken);

                    return(TryInstallAndAddUndoAction(
                               source, packageName, versionOpt, includePrerelease, dte, dteProject, undoManager));
                }
            }

            return(false);
        }
        public UaBrowserViewModel(Microsoft.VisualStudio.Shell.SVsServiceProvider vsServiceProvider)
        {
            this.cts   = new CancellationTokenSource();
            this.@lock = new SemaphoreSlim(1);

            // describe self.
            this.localDescription = new ApplicationDescription()
            {
                ApplicationName = "Workstation.UaBrowser",
                ApplicationUri  = $"urn:{System.Net.Dns.GetHostName()}:Workstation.UaBrowser",
                ApplicationType = ApplicationType.Client
            };

            this.BrowseStopCommand    = new DelegateCommand(this.BrowseStop);
            this.SaveSettingsCommand  = new DelegateCommand(this.SaveSettings);
            this.ResetSettingsCommand = new DelegateCommand(this.ResetSettings);
            this.NamespaceItems       = new ObservableCollection <ReferenceDescriptionViewModel>();
            this.ide = (EnvDTE.DTE)vsServiceProvider.GetService(typeof(EnvDTE.DTE));
            var shellSettingsManager = new ShellSettingsManager(vsServiceProvider);

            this.store = shellSettingsManager.GetWritableSettingsStore(SettingsScope.UserSettings);

            this.LoadSettings();
            this.LoadHistory();
            this.CertificateStore = new DirectoryStore(Environment.ExpandEnvironmentVariables(@"%LOCALAPPDATA%\Workstation.UaBrowser\pki"));
        }
        public MarkdownLanguageInfo(SVsServiceProvider serviceProvider)
        {
            _serviceProvider = serviceProvider;

            IVsTextManager2 textManager = (IVsTextManager2)serviceProvider.GetService(typeof(SVsTextManager));
            LANGPREFERENCES2[] preferences = new LANGPREFERENCES2[1];
            preferences[0].guidLang = typeof(MarkdownLanguageInfo).GUID;
            ErrorHandler.ThrowOnFailure(textManager.GetUserPreferences2(null, null, preferences, null));
            _languagePreferences = CreateLanguagePreferences(preferences[0]);
            _languagePreferencesCookie = ((IConnectionPointContainer)textManager).Advise<LanguagePreferences, IVsTextManagerEvents2>(_languagePreferences);
        }
Exemple #4
0
        public MarkdownLanguageInfo(SVsServiceProvider serviceProvider)
        {
            _serviceProvider = serviceProvider;

            IVsTextManager2 textManager = (IVsTextManager2)serviceProvider.GetService(typeof(SVsTextManager));

            LANGPREFERENCES2[] preferences = new LANGPREFERENCES2[1];
            preferences[0].guidLang = typeof(MarkdownLanguageInfo).GUID;
            ErrorHandler.ThrowOnFailure(textManager.GetUserPreferences2(null, null, preferences, null));
            _languagePreferences       = CreateLanguagePreferences(preferences[0]);
            _languagePreferencesCookie = ((IConnectionPointContainer)textManager).Advise <LanguagePreferences, IVsTextManagerEvents2>(_languagePreferences);
        }
Exemple #5
0
        /// <summary>
        ///     Gets an object that represents a host-specific IVsContainedLanguageFactory implementation and
        ///     IVsHierarchy and itemId specific to currently active target framework.
        /// </summary>
        /// <param name="filePath">Path to a file</param>
        /// <param name="hierarchy">Project hierarchy containing given file for current language service</param>
        /// <param name="itemid">item id of the given file</param>
        /// <param name="containedLanguageFactory">an instance of IVsContainedLanguageFactory specific for current language service</param>
        /// <returns></returns>
        public int GetContainedLanguageFactoryForFile(string filePath,
                                                      out IVsHierarchy hierarchy,
                                                      out uint itemid,
                                                      out IVsContainedLanguageFactory containedLanguageFactory)
        {
            uint         myItemId    = 0;
            IVsHierarchy myHierarchy = null;
            IVsContainedLanguageFactory myContainedLanguageFactory = null;

            _projectVsServices.ThreadingService.JoinableTaskFactory.Run(async() =>
            {
                await InitializeAsync().ConfigureAwait(false);

                Guid?languageServiceId = await GetLanguageServiceId().ConfigureAwait(false);
                if (languageServiceId == null)
                {
                    return;
                }

                await _projectVsServices.ThreadingService.JoinableTaskFactory.SwitchToMainThreadAsync();

                var priority   = new VSDOCUMENTPRIORITY[1];
                HResult result = _projectVsServices.VsProject.IsDocumentInProject(filePath,
                                                                                  out int isFound,
                                                                                  priority,
                                                                                  out myItemId);
                if (result.Failed || isFound == 0)
                {
                    return;
                }

                myHierarchy = (IVsHierarchy)_projectHostProvider.UnconfiguredProjectHostObject.ActiveIntellisenseProjectHostObject;

                var oleServiceProvider = _serviceProvider.GetService(typeof(IOLEServiceProvider)) as IOLEServiceProvider;
                if (oleServiceProvider == null)
                {
                    return;
                }

                myContainedLanguageFactory = (IVsContainedLanguageFactory)PackageUtilities.QueryService(
                    oleServiceProvider,
                    languageServiceId.Value);
            });

            hierarchy = myHierarchy;
            itemid    = myItemId;
            containedLanguageFactory = myContainedLanguageFactory;

            return((myHierarchy == null || containedLanguageFactory == null)
                ? VSConstants.E_FAIL
                : VSConstants.S_OK);
        }
Exemple #6
0
        public IMouseProcessor GetAssociatedProcessor(IWpfTextView view)
        {
            if (App.OptionsPage?.DisableShiftClick == null)
            {
                return(null);
            }

            //if (!(GlobalServiceProvider.GetService(typeof(SUIHostCommandDispatcher)) is IOleCommandTarget shellCommandDispatcher))
            //    return null;

            return(new GoToModuleMouseHandler(
                       (DTE2)GlobalServiceProvider.GetService(typeof(SDTE)),
                       view,
                       //shellCommandDispatcher,
                       AggregatorFactory.GetClassifier(view.TextBuffer),
                       NavigatorService.GetTextStructureNavigator(view.TextBuffer),
                       CtrlKeyState.GetStateForView(view)));
        }
 public CatchSettingsService(Microsoft.VisualStudio.Shell.SVsServiceProvider serviceProvider)
 {
     this.dte = (DTE)serviceProvider.GetService(typeof(DTE));
 }