Пример #1
0
        protected void PrepareRequiredConnection(SSHConnectionInfo requiredConnectionInfo)
        {
            if (requiredConnectionInfo == null)
            {
                return;
            }
            var additionalPF = new PortForwarding
            {
                Type       = "Local",
                RemoteHost = ConnectionInfo.Host,
                RemotePort = ConnectionInfo.Port,
            };
            // Try to re-use recently used port.
            var recentlyUsedPort = ConnectionInfo.GetAvailableCachedPort();

            if (recentlyUsedPort > 0)
            {
                additionalPF.LocalPort = recentlyUsedPort;
            }
            var conn = new SSHConnectionViewModel(requiredConnectionInfo, false, additionalPF)
            {
                Parent = this
            };

            conn.IsRoot.Value  = false;
            RequiredConnection = conn;
            Children.Add(conn);
        }
Пример #2
0
        public static ConnectionViewModel <T> CreateFromConnectionInfo(T info)
        {
            if (info == null)
            {
                throw new ArgumentNullException(nameof(info));
            }

            ConnectionViewModel <T> vm;

            if (info is RDPConnectionInfo)
            {
                vm = new RDPConnectionViewModel(info as RDPConnectionInfo) as ConnectionViewModel <T>;
            }
            else if (info is SSHConnectionInfo)
            {
                vm = new SSHConnectionViewModel(info as SSHConnectionInfo) as ConnectionViewModel <T>;
            }
            else
            {
                throw new ArgumentException($"{info.GetType()} is not available connection info.", nameof(info));
            }
            vm.IsRoot.Value = true;
            return(vm);
        }