Пример #1
0
        /// <summary>
        /// Create a new pipe connection object
        /// </summary>
        /// <param name="pipeTransportSettings">Settings</param>
        /// <param name="outerConnection">[Optional] the SSH connection (or maybe something else in future) used to connect to the target.</param>
        /// <param name="name">The full name of this connection</param>
        public PipeConnection(IPipeTransportSettings pipeTransportSettings, Connection outerConnection, string name)
        {
            Debug.Assert(pipeTransportSettings != null);
            Debug.Assert(!string.IsNullOrWhiteSpace(name));

            _name            = name;
            _settings        = pipeTransportSettings;
            _outerConnection = outerConnection;
        }
Пример #2
0
        /// <summary>
        /// Create a new pipe connection object
        /// </summary>
        /// <param name="pipeTransportSettings">Settings</param>
        /// <param name="outerConnection">[Optional] the SSH connection (or maybe something else in future) used to connect to the target.</param>
        /// <param name="name">The full name of this connection</param>
        public PipeConnection(IPipeTransportSettings pipeTransportSettings, Connection outerConnection, string name)
        {
            Debug.Assert(pipeTransportSettings != null);
            Debug.Assert(!string.IsNullOrWhiteSpace(name));

            _name                  = name;
            _settings              = pipeTransportSettings;
            _outerConnection       = outerConnection;
            _shellExecutionManager = new ShellExecutionManager(CreateShellFromSettings(_settings, _outerConnection));
        }
Пример #3
0
        internal ICommandRunner CreateShellFromSettings(IPipeTransportSettings settings, Connection outerConnection, bool isCommandShell = false)
        {
            ICommandRunner rawShell;

            if (_outerConnection == null)
            {
                if (isCommandShell)
                {
                    rawShell = new LocalRawCommandRunner(settings.ExeCommand, settings.ExeCommandArgs);
                }
                else
                {
                    rawShell = new LocalBufferedCommandRunner(settings.ExeCommand, settings.ExeCommandArgs);
                }
            }
            else
            {
                rawShell = new RemoteCommandRunner(settings.ExeCommand, settings.ExeCommandArgs, outerConnection);
            }

            lock (_lock)
            {
                _shellList.Add(rawShell);
            }

            rawShell.Closed += (sender, eventArgs) =>
            {
                if (_isClosed)
                {
                    return;
                }

                lock (_lock)
                {
                    if (_isClosed)
                    {
                        return;
                    }

                    _shellList.Remove(rawShell);
                }
            };

            return(rawShell);
        }