Exemple #1
0
        private TextWriter CreateWriter(Guid id, string title)
        {
            var stringWriter = new StringWriter();
            var writer       = new StrategyTextWriter(stringWriter);

            eventStream.Value.Of <ShellInitialized>().Subscribe(_ =>
            {
                using (tracer.StartActivity(Strings.OutputWindowManager.TraceInitializing(title)))
                {
                    IVsOutputWindowPane pane = GetVsPane(id, title);
                    if (pane != null)
                    {
                        var outputWriter = new OutputWindowTextWriter(jtf, pane);

                        // Dump over the cached text from the initial writer.
                        stringWriter.Flush();
                        outputWriter.Write(stringWriter.ToString());

                        // Replace the strategy, which will now write directly to the output pane.
                        writer.StrategyWriter = outputWriter;
                    }
                }
            });

            return(writer);
        }
        private TextWriter CreateWriter(Guid id, string title)
        {
            var stringWriter = new StringWriter();
            var writer       = new StrategyTextWriter(stringWriter);

            shellEvents.Initialized += (sender, args) =>
            {
                using (tracer.StartActivity(Strings.OutputWindowManager.TraceInitializing(title)))
                {
                    IVsOutputWindowPane pane = GetVsPane(id, title);
                    if (pane != null)
                    {
                        var outputWriter = new OutputWindowTextWriter(uiThread, pane);

                        // Dump over the cached text from the initial writer.
                        stringWriter.Flush();
                        outputWriter.Write(stringWriter.ToString());

                        // Replace the strategy, which will now write directly to the output pane.
                        writer.StrategyWriter = outputWriter;
                    }
                }
            };

            return(writer);
        }
Exemple #3
0
        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();
        }
        private TextWriter CreateWriter(Guid id, string title)
        {
            var stringWriter = new StringWriter();
            var writer = new StrategyTextWriter(stringWriter);

            shellEvents.Initialized += (sender, args) =>
            {
                using (tracer.StartActivity(Strings.OutputWindowManager.TraceInitializing(title)))
                {
                    IVsOutputWindowPane pane = GetVsPane(id, title);
                    if (pane != null)
                    {
                        var outputWriter = new OutputWindowTextWriter(uiThread, pane);

                        // Dump over the cached text from the initial writer.
                        stringWriter.Flush();
                        outputWriter.Write(stringWriter.ToString());

                        // Replace the strategy, which will now write directly to the output pane.
                        writer.StrategyWriter = outputWriter;
                    }
                }
            };

            return writer;
        }