示例#1
0
        public ConsoleDispatcher(IPrivateWpfConsole wpfConsole)
        {
            if (wpfConsole == null)
            {
                throw new ArgumentNullException("wpfConsole");
            }

            WpfConsole = wpfConsole;
        }
示例#2
0
        public ConsoleDispatcher(IPrivateWpfConsole wpfConsole)
        {
            if (wpfConsole == null)
              {
            throw new ArgumentNullException("wpfConsole");
              }

              WpfConsole = wpfConsole;
        }
        public bool Execute(string command, object[] inputs)
        {
            if (ConsoleStatus.IsBusy)
            {
                VSOutputConsole.WriteLine(Resources.PackageManagerConsoleBusy);
                throw new NotSupportedException(Resources.PackageManagerConsoleBusy);
            }

            if (!String.IsNullOrEmpty(command))
            {
                WpfConsole.SetExecutionMode(true);
                // Cast the ToolWindowPane to PowerConsoleToolWindow
                // Access the IHost from PowerConsoleToolWindow as follows PowerConsoleToolWindow.WpfConsole.Host
                // Cast IHost to IAsyncHost
                // Also, register for IAsyncHost.ExecutedEnd and return only when the command is completed
                IPrivateWpfConsole powerShellConsole = (IPrivateWpfConsole)WpfConsole;
                IHost host = powerShellConsole.Host;

                var asynchost = host as IAsyncHost;
                if (asynchost != null)
                {
                    asynchost.ExecuteEnd += PowerConsoleCommand_ExecuteEnd;
                }

                // Here, we store the snapshot of the powershell Console output text buffer
                // Snapshot has reference to the buffer and the current length of the buffer
                // And, upon execution of the command, (check the commandexecuted handler)
                // the changes to the buffer is identified and copied over to the VS output window
                if (powerShellConsole.InputLineStart != null &&
                    powerShellConsole.InputLineStart.Value.Snapshot != null)
                {
                    _snapshot = powerShellConsole.InputLineStart.Value.Snapshot;
                }

                // We should write the command to the console just to imitate typical user action before executing it
                // Asserts get fired otherwise. Also, the log is displayed in a disorderly fashion
                powerShellConsole.WriteLine(command);

                return(host.Execute(powerShellConsole, command, null));
            }
            return(false);
        }
示例#4
0
        public ConsoleDispatcher(IPrivateWpfConsole wpfConsole)
        {
            UtilityMethods.ThrowIfArgumentNull(wpfConsole);

            this.WpfConsole = wpfConsole;
        }