Example #1
0
        /// <summary>
        /// Gets the global <see cref="IGlyphService"/> service.
        /// </summary>
        /// <param name="serviceProvider">The service provider.</param>
        /// <returns>The <see cref="IGlyphService"/> service provided by the service provider, or <see langword="null"/> if the service provider was not able to provide an instance of the service.</returns>
        /// <exception cref="ArgumentNullException">If <paramref name="serviceProvider"/> is <see langword="null"/>.</exception>
        public static IGlyphService GetGlyphService(this SVsServiceProvider serviceProvider)
        {
            if (serviceProvider == null)
            {
                throw new ArgumentNullException(nameof(serviceProvider));
            }

            return(serviceProvider.GetComponentModel().GetService <IGlyphService>());
        }
        public int GetCodeWindowManager(IVsCodeWindow pCodeWin, out IVsCodeWindowManager ppCodeWinMgr)
        {
            var adaptersFactory = _serviceProvider.GetComponentModel().GetService <IVsEditorAdaptersFactoryService>();

            IVsTextLines textLines;

            ErrorHandler.ThrowOnFailure(pCodeWin.GetBuffer(out textLines));
            var textBuffer = adaptersFactory.GetDataBuffer(textLines);

            if (textBuffer == null)
            {
                ppCodeWinMgr = null;
                return(VSConstants.E_FAIL);
            }

            ppCodeWinMgr = _languagePackage.GetOrCreateCodeWindowManager(pCodeWin);
            return(VSConstants.S_OK);
        }
        protected virtual bool TryCreateDropdownBarClient(out int comboBoxCount, out IVsDropdownBarClient client)
        {
            var componentModel        = _serviceProvider.GetComponentModel();
            var dropdownBarFactory    = componentModel.DefaultExportProvider.GetExportedValueOrDefault <IEditorNavigationDropdownBarFactoryService>();
            var editorAdaptersFactory = componentModel.DefaultExportProvider.GetExportedValueOrDefault <IVsEditorAdaptersFactoryService>();

            editorAdaptersFactory.GetWpfTextView(_codeWindow.GetPrimaryView());
            var dropdownBarClient = dropdownBarFactory.CreateEditorNavigationDropdownBar(CodeWindow, editorAdaptersFactory);

            if (dropdownBarClient == null || dropdownBarClient.DropdownCount == 0)
            {
                comboBoxCount = 0;
                client        = null;
                return(false);
            }

            comboBoxCount = dropdownBarClient.DropdownCount;
            client        = dropdownBarClient;
            return(true);
        }
Example #4
0
 public static IGlyphService GetGlyphService([NotNull] this SVsServiceProvider serviceProvider)
 {
     Requires.NotNull(serviceProvider, nameof(serviceProvider));
     return(serviceProvider.GetComponentModel().GetService <IGlyphService>());
 }
 /// <summary>
 /// Gets the global <see cref="IGlyphService"/> service.
 /// </summary>
 /// <param name="serviceProvider">The service provider.</param>
 /// <returns>The <see cref="IGlyphService"/> service provided by the service provider, or <see langword="null"/> if the service provider was not able to provide an instance of the service.</returns>
 /// <exception cref="ArgumentNullException">If <paramref name="serviceProvider"/> is <see langword="null"/>.</exception>
 public static IGlyphService GetGlyphService(this SVsServiceProvider serviceProvider)
 {
     Contract.Requires <ArgumentNullException>(serviceProvider != null, "serviceProvider");
     return(serviceProvider.GetComponentModel().GetService <IGlyphService>());
 }