Implements calling GuiMacro to the remote ConEmu instance, and getting the result.

Got switching implementation for out-of-process (classic, via a console tool) and in-process (new feature which loads the helper comm DLL directly) access.

Наследование: IDisposable
Пример #1
0
        /// <summary>
        /// Starts the session.
        /// Opens the emulator view in the control (HWND given in <paramref name="hostcontext" />) by starting the ConEmu child process and giving it that HWND; ConEmu then starts the child Console Process for the commandline given in <paramref name="startinfo" /> and makes it run in the console emulator window.
        /// </summary>
        /// <param name="startinfo">User-defined startup parameters for the console process.</param>
        /// <param name="hostcontext">Control-related parameters.</param>
        /// <param name="joinableTaskFactory">The <see cref="JoinableTaskFactory"/>.</param>
        public ConEmuSession([NotNull] ConEmuStartInfo startinfo, [NotNull] HostContext hostcontext, [NotNull] JoinableTaskFactory joinableTaskFactory)
        {
            if (startinfo == null)
            {
                throw new ArgumentNullException(nameof(startinfo));
            }
            if (hostcontext == null)
            {
                throw new ArgumentNullException(nameof(hostcontext));
            }
            if (joinableTaskFactory == null)
            {
                throw new ArgumentNullException(nameof(joinableTaskFactory));
            }
            if (string.IsNullOrEmpty(startinfo.ConsoleProcessCommandLine))
            {
                throw new InvalidOperationException($"Cannot start a new console process for command line “{startinfo.ConsoleProcessCommandLine}” because it's either NULL, or empty, or whitespace.");
            }

            _joinableTaskFactory = joinableTaskFactory;
            _startinfo           = startinfo;
            startinfo.MarkAsUsedUp();             // No more changes allowed in this copy

            // Directory for working files, +cleanup
            _dirTempWorkingFolder = Init_TempWorkingFolder();

            // Events wiring: make sure sinks pre-installed with start-info also get notified
            Init_WireEvents(startinfo);

            // Should feed ANSI log?
            if (startinfo.IsReadingAnsiStream)
            {
                _ansilog = Init_AnsiLog(startinfo);
            }

            // Cmdline
            CommandLineBuilder cmdl = Init_MakeConEmuCommandLine(startinfo, hostcontext, _ansilog, _dirTempWorkingFolder);

            // Start ConEmu
            // If it fails, lifetime will be terminated; from them on, termination will be bound to ConEmu process exit
            _process = Init_StartConEmu(startinfo, cmdl);

            // GuiMacro executor
            _guiMacroExecutor = new GuiMacroExecutor(startinfo.ConEmuConsoleServerExecutablePath);
            _lifetime.Add(() => ((IDisposable)_guiMacroExecutor).Dispose());

            // Monitor payload process
            Init_ConsoleProcessMonitoring();
        }
Пример #2
0
		/// <summary>
		/// Starts the session.
		/// Opens the emulator view in the control (HWND given in <paramref name="hostcontext" />) by starting the ConEmu child process and giving it that HWND; ConEmu then starts the child Console Process for the commandline given in <paramref name="startinfo" /> and makes it run in the console emulator window.
		/// </summary>
		/// <param name="startinfo">User-defined startup parameters for the console process.</param>
		/// <param name="hostcontext">Control-related parameters.</param>
		public ConEmuSession([NotNull] ConEmuStartInfo startinfo, [NotNull] HostContext hostcontext)
		{
			if(startinfo == null)
				throw new ArgumentNullException(nameof(startinfo));
			if(hostcontext == null)
				throw new ArgumentNullException(nameof(hostcontext));
			if(string.IsNullOrEmpty(startinfo.ConsoleProcessCommandLine))
				throw new InvalidOperationException($"Cannot start a new console process for command line “{startinfo.ConsoleProcessCommandLine}” because it's either NULL, or empty, or whitespace.");

			_startinfo = startinfo;
			startinfo.MarkAsUsedUp(); // No more changes allowed in this copy

			// Directory for working files, +cleanup
			_dirTempWorkingFolder = Init_TempWorkingFolder();

			// Events wiring: make sure sinks pre-installed with start-info also get notified
			Init_WireEvents(startinfo);

			// Should feed ANSI log?
			if(startinfo.IsReadingAnsiStream)
				_ansilog = Init_AnsiLog(startinfo);

			// Cmdline
			CommandLineBuilder cmdl = Init_MakeConEmuCommandLine(startinfo, hostcontext, _ansilog, _dirTempWorkingFolder);

			// Start ConEmu
			// If it fails, lifetime will be terminated; from them on, termination will be bound to ConEmu process exit
			_process = Init_StartConEmu(startinfo, cmdl);

			// GuiMacro executor
			_guiMacroExecutor = new GuiMacroExecutor(startinfo.ConEmuConsoleServerExecutablePath);
			_lifetime.Add(() => ((IDisposable)_guiMacroExecutor).Dispose());

			// Monitor payload process
			Init_ConsoleProcessMonitoring();
		}