Exemplo n.º 1
0
        //---

        private CommandResult ExecuteCommand()
        {
            try
            {
                const string semi_colon   = ";";
                var          pane         = Package?.PackageOutputPane;
                var          colonNewline = semi_colon + NewLine;
                var          expanded     = ExpandEnvironmentVariables("%path%");
                var          text         = expanded.Replace(semi_colon, colonNewline);

                text += colonNewline;

                var result = Package?.ActivateOutputWindow();
                if (!result.Succeeded)
                {
                    return(result);
                }

                pane.Activate();
                pane.Clear();
                pane.OutputString("Path Variables" + NewLine);
                pane.OutputString("==============" + NewLine + NewLine);
                pane.OutputString(text);

                return(new SuccessResult());
            }
            catch (Exception ex)
            {
                return(new ProblemResult(ex.ExtendedMessage()));
            }
        }
#pragma warning restore VSTHRD010 // Invoke single-threaded types on Main thread

        private static CommandResult ExecuteCommand()
        {
            try
            {
                ThreadHelper.ThrowIfNotOnUIThread(nameof(EnvironmentVariablesCommand));

                //const string semi_colon = ";";
                //var colonNewline = semi_colon + NewLine;
                var pane      = Package?.PackageOutputPane;
                var variables = GetEnvironmentVariableOutput();

                //text += colonNewline;

                var result = Package?.ActivateOutputWindow();
                if (!result.Succeeded)
                {
                    return(result);
                }

                pane?.Activate();
                pane?.Clear();
                pane?.OutputString("Environment Variables" + NewLine);
                pane?.OutputString("=====================" + NewLine + NewLine);
                pane?.OutputString(variables);

                return(new SuccessResult());
            }
            catch (Exception ex)
            {
                return(new ProblemResult(ex.ExtendedMessage()));
            }
        }
        /// <inheritdoc />
        /// <summary>
        ///     Called when [execute].
        /// </summary>
        /// <param name="command">The command.</param>
        protected override void OnExecute(OleMenuCommand command)
        {
            var pane = Package?.PackageOutputPane;

            if (pane == null || Package?.ActivateOutputWindow() == false)
            {
                return;
            }

            const string semiColon = ";";
            var          expanded  = System.Environment.ExpandEnvironmentVariables("%path%");
            var          text      = expanded.Replace(semiColon, System.Environment.NewLine);

            pane.Activate();
            pane.Clear();
            pane.OutputString("Path Variables" + System.Environment.NewLine);
            pane.OutputString("==============" + System.Environment.NewLine);
            pane.OutputString(text);
        }
Exemplo n.º 4
0
        private static CommandResult ExecuteCommand()
        {
            try
            {
                ThreadHelper.ThrowIfNotOnUIThread();

                //var threadingService = Package?.GetService<IProjectThreadingService>();

                const string semi_colon   = ";";
                var          colonNewline = semi_colon + NewLine;
                var          expanded     = ExpandEnvironmentVariables("%path%");
                var          text         = expanded.Replace(semi_colon, colonNewline);

                text += colonNewline;

                var result = Package?.ActivateOutputWindow();
                if (!result.Succeeded)
                {
                    return(result);
                }

                //if (!threadingService.IsOnMainThread)
                //    return new ProblemResult("Cannot execute command (not on main thread)");

                var pane = Package?.PackageOutputPane;

                pane?.Activate();
                pane?.Clear();
                pane?.OutputString("Path Variables" + NewLine);
                pane?.OutputString("==============" + NewLine + NewLine);
                pane?.OutputString(text);

                return(new SuccessResult());
            }
            catch (Exception ex)
            {
                return(new ProblemResult(ex.ExtendedMessage()));
            }
        }