/// <summary> /// Initializes a new instance of the <see cref="ScpClient"/> class. /// </summary> /// <param name="connectionInfo">The connection info.</param> /// <param name="ownsConnectionInfo">Specified whether this instance owns the connection info.</param> /// <param name="serviceFactory">The factory to use for creating new services.</param> /// <exception cref="ArgumentNullException"><paramref name="connectionInfo"/> is <c>null</c>.</exception> /// <exception cref="ArgumentNullException"><paramref name="serviceFactory"/> is <c>null</c>.</exception> /// <remarks> /// If <paramref name="ownsConnectionInfo"/> is <c>true</c>, then the /// connection info will be disposed when this instance is disposed. /// </remarks> internal ScpClient(ConnectionInfo connectionInfo, bool ownsConnectionInfo, IServiceFactory serviceFactory) : base(connectionInfo, ownsConnectionInfo, serviceFactory) { OperationTimeout = SshNet.Session.InfiniteTimeSpan; BufferSize = 1024 * 16; _remotePathTransformation = serviceFactory.CreateRemotePathDoubleQuoteTransformation(); }
/// <summary> /// Defines a SSH transaction /// </summary> /// <param name="_cred">The SSH transaction credentials</param> /// <param name="task">The Transaction task</param> /// <param name="remotePath">Changes how the remote path is transformed before /// it is passed to the scp command on the remote server. /// DoubleQuote, ShellQuote, None</param> public static void SSHTransactionVoid(SiteCredentials _cred, Action <AuraSftpClient> task, IRemotePathTransformation remotePath = null) { using (var client = new AuraSftpClient(_cred)) { try { if (remotePath == null) { client.RemotePathTransformation = ShellQuote; } else { client.RemotePathTransformation = remotePath; } client.Connect(); task(client); client.Disconnect(); } catch (System.Exception exc) { Console.WriteLine(exc.Message); } } }
/// <summary> /// Defines a SSH transaction /// </summary> /// <param name="_cred">The SSH transaction credentials</param> /// <param name="task">The Transaction task</param> /// <param name="remotePath">Changes how the remote path is transformed before /// it is passed to the scp command on the remote server. /// DoubleQuote, ShellQuote, None</param> /// <returns>The transaction result</returns> public static T SSHTransactionGen <T>(SiteCredentials _cred, Func <AuraSftpClient, T> task, IRemotePathTransformation remotePath = null) where T : class => (T)SSHTransaction(_cred, task);
/// <summary> /// Defines a SSH transaction /// </summary> /// <param name="_cred">The SSH transaction credentials</param> /// <param name="task">The Transaction task</param> /// <param name="remotePath">Changes how the remote path is transformed before /// it is passed to the scp command on the remote server. /// DoubleQuote, ShellQuote, None</param> /// <returns>The transaction result</returns> public static Object SSHTransaction(SiteCredentials _cred, Func <AuraSftpClient, Object> task, IRemotePathTransformation remotePath = null) { Object result = null; using (var client = new AuraSftpClient(_cred)) { try { if (remotePath == null) { client.RemotePathTransformation = ShellQuote; } else { client.RemotePathTransformation = remotePath; } client.Connect(); result = task(client); client.Disconnect(); } catch (System.Exception exc) { Console.WriteLine(exc.Message); } } return(result); }
public void SetUp() { _transformation = new RemotePathDoubleQuoteTransformation(); }
public void SetUp() { _transformation = new RemotePathShellQuoteTransformation(); }