protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress) { var componenModel = (IComponentModel) await GetServiceAsync(typeof(SComponentModel)).ConfigureAwait(false); Assumes.Present(componenModel); Workspace = componenModel.GetService <VisualStudioWorkspace>(); string hostBasePath = Path.Combine( Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) !, "Host"); HostRunner = HostRunner.GetHostRunner(hostBasePath, TargetFramework.Net5Plus, Platform.x64, #if DEBUG debug: true, waitForDebugger: false #else debug: false, waitForDebugger: false #endif ); HostRunner.MessageReceived += message => JoinableTaskFactory.Run( async() => await OutWriter.WriteLineAsync($"HOST ({HostRunner.Id}): " + message)); var mcs = (OleMenuCommandService) await GetServiceAsync(typeof(IMenuCommandService)).ConfigureAwait(false); Assumes.Present(mcs); await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); OutWriter = new OutputWindowTextWriter(GetOutputPane(PackageGuids.OutputWindowPane, "Layout Analyzer")); mcs.AddCommand(new MenuCommand( ShowLayoutWindow, new CommandID(PackageGuids.CommandSet, PackageIds.LayoutWindowCommand))); mcs.AddCommand(new MenuCommand( Analyze, new CommandID(PackageGuids.ContextMenuCommandSet, PackageIds.AnalyzeCommand))); DTE = (DTE2) await GetServiceAsync(typeof(SDTE)); Assumes.Present(DTE); FontAndColorStorage = (IVsFontAndColorStorage) await GetServiceAsync(typeof(SVsFontAndColorStorage)); Assumes.Present(FontAndColorStorage); //Solution = (IVsSolution)await GetServiceAsync(typeof(SVsSolution)); //SolutionEventSink = await SolutionEventSink.SubscribeAsync(); //RunningDocumentTable = (IVsRunningDocumentTable)await GetServiceAsync(typeof(SVsRunningDocumentTable)); //RunningDocumentTableEventSink = await RunningDocumentTableEventSink.SubscribeAsync(); TextManager = (IVsTextManager) await GetServiceAsync(typeof(SVsTextManager)); Assumes.Present(TextManager); TextManagerEventSink = await TextManagerEventSink.SubscribeAsync(); }
protected override void Dispose(bool disposing) { try { ThreadHelper.ThrowIfNotOnUIThread(); if (disposing) { //SolutionEventSink?.Dispose(); //SolutionEventSink = null; TextManagerEventSink?.Dispose(); TextManagerEventSink = null; } } finally { base.Dispose(disposing); } }