Esempio n. 1
0
 private Microsoft.VisualStudio.Editor.IVsEditorAdaptersFactoryService GetEditorAdaptersFactoryService()
 {
     Microsoft.VisualStudio.ComponentModelHost.IComponentModel componentModel =
         (Microsoft.VisualStudio.ComponentModelHost.IComponentModel)_serviceProvider.GetService(
             typeof(Microsoft.VisualStudio.ComponentModelHost.SComponentModel));
     return(componentModel.GetService <Microsoft.VisualStudio.Editor.IVsEditorAdaptersFactoryService>());
 }
            public TextBufferEventListener(IComponentModel componentModel, IVsTextLines textLines)
            {
                this._componentModel = componentModel;
                this._textLines      = textLines;

                var connectionPointContainer = textLines as IConnectionPointContainer;
                var bufferEventsGuid         = typeof(IVsTextBufferDataEvents).GUID;

                connectionPointContainer.FindConnectionPoint(ref bufferEventsGuid, out _connectionPoint);
                _connectionPoint.Advise(this, out _cookie);
            }
            public TextBufferEventListener(IComponentModel compModel, IVsTextLines textLines, IVsTextManager textMgr, IVsCodeWindow window)
            {
                _textLines = textLines;
                _compModel = compModel;
                _textMgr = textMgr;
                _window = window;

                var cpc = textLines as IConnectionPointContainer;
                var bufferEventsGuid = typeof(IVsTextBufferDataEvents).GUID;
                cpc.FindConnectionPoint(ref bufferEventsGuid, out _cp);
                _cp.Advise(this, out _cookie);
            }
            public TextBufferEventListener(IComponentModel componentModel, IVsTextLines textLines, Guid languageServiceId)
            {
                _componentModel    = componentModel;
                _textLines         = textLines;
                _languageServiceId = languageServiceId;

                var connectionPointContainer = textLines as IConnectionPointContainer;
                var bufferEventsGuid         = typeof(IVsTextBufferDataEvents).GUID;

                connectionPointContainer.FindConnectionPoint(ref bufferEventsGuid, out _connectionPoint);
                _connectionPoint.Advise(this, out _cookie);
            }
Esempio n. 5
0
            public TextBufferEventListener(IComponentModel compModel, IVsTextLines textLines, IVsTextManager textMgr, IVsCodeWindow window)
            {
                _textLines = textLines;
                _compModel = compModel;
                _textMgr   = textMgr;
                _window    = window;

                var cpc = textLines as IConnectionPointContainer;
                var bufferEventsGuid = typeof(IVsTextBufferDataEvents).GUID;

                cpc.FindConnectionPoint(ref bufferEventsGuid, out _cp);
                _cp.Advise(this, out _cookie);
            }
Esempio n. 6
0
        /// <summary>
        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initialization code that rely on services provided by VisualStudio.
        /// </summary>
        /// <param name="cancellationToken">A cancellation token to monitor for initialization cancellation, which can occur when VS is shutting down.</param>
        /// <param name="progress">A provider for progress updates.</param>
        /// <returns>A task representing the async work of package initialization, or an already completed task if there is none. Do not return null from this method.</returns>
        protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress)
        {
            // When initialized asynchronously, the current thread may be a background thread at this point.
            // Do any initialization that requires the UI thread after switching to the UI thread.
            await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);

            var _dte2 = (DTE2)GetGlobalService(typeof(SDTE));
            var sp    = new ServiceProvider(_dte2 as Microsoft.VisualStudio.OLE.Interop.IServiceProvider);

            componentModel = sp.GetService(typeof(Microsoft.VisualStudio.ComponentModelHost.SComponentModel)) as Microsoft.VisualStudio.ComponentModelHost.IComponentModel;
            Assumes.Present(componentModel);
            await OutputToolWindowCommand.InitializeAsync(this);
        }
            public TextBufferEventListener(IComponentModel componentModel, IVsTextLines textLines)
            {
                this._componentModel = componentModel;
                this._textLines = textLines;

                var connectionPointContainer = textLines as IConnectionPointContainer;
                var bufferEventsGuid = typeof(IVsTextBufferDataEvents).GUID;
                connectionPointContainer.FindConnectionPoint(ref bufferEventsGuid, out _connectionPoint);
                _connectionPoint.Advise(this, out _cookie);
            }