private void LoadProfile(FtpProfile profile) { // verify args if (profile == null) { throw new ArgumentException("Required parameter is null or blank.", "profile"); } if (profile.Host.IsBlank()) { throw new ArgumentException("Required parameter is null or blank.", "profile.Host"); } if (profile.Credentials == null) { throw new ArgumentException("Required parameter is null.", "profile.Credentials"); } if (profile.Encoding == null) { throw new ArgumentException("Required parameter is null.", "profile.Encoding"); } // copy over the profile properties to this instance Host = profile.Host; Credentials = profile.Credentials; EncryptionMode = profile.Encryption; SslProtocols = profile.Protocols; DataConnectionType = profile.DataConnection; Encoding = profile.Encoding; }
/// <summary> /// Connect to the given server profile. /// </summary> public async Task ConnectAsync(FtpProfile profile, CancellationToken token = default(CancellationToken)) { // copy over the profile properties to this instance LoadProfile(profile); // begin connection await ConnectAsync(token); }
/// <summary> /// Connect to the given server profile. /// </summary> public void Connect(FtpProfile profile) { // copy over the profile properties to this instance LoadProfile(profile); // begin connection Connect(); }
/// <summary> /// Connect to the given server profile. /// </summary> public async Task ConnectAsync(FtpProfile profile, CancellationToken token = default(CancellationToken)) { // copy over the profile properties to this instance Host = profile.Host; Credentials = profile.Credentials; EncryptionMode = profile.Encryption; SslProtocols = profile.Protocols; DataConnectionType = profile.DataConnection; Encoding = profile.Encoding; // begin connection await ConnectAsync(token); }
/// <summary> /// Connect to the given server profile. /// </summary> public void Connect(FtpProfile profile) { // copy over the profile properties to this instance Host = profile.Host; Credentials = profile.Credentials; EncryptionMode = profile.Encryption; SslProtocols = profile.Protocols; DataConnectionType = profile.DataConnection; Encoding = profile.Encoding; // begin connection Connect(); }
private void SetDefaultCertificateValidation(FtpProfile profile) { if (profile.Encryption != FtpEncryptionMode.None) { ValidateCertificate += new FtpSslValidation(delegate(FtpClient c, FtpSslValidationEventArgs e) { if (e.PolicyErrors != System.Net.Security.SslPolicyErrors.None) { e.Accept = false; } else { e.Accept = true; } }); } }
/// <summary> /// Load the given connection profile and configure the FTP client instance accordingly. /// </summary> /// <param name="profile">Connection profile. Not modified.</param> public void LoadProfile(FtpProfile profile) { // verify args if (profile == null) { throw new ArgumentException("Required parameter is null or blank.", "profile"); } if (profile.Host.IsBlank()) { throw new ArgumentException("Required parameter is null or blank.", "profile.Host"); } if (profile.Credentials == null) { throw new ArgumentException("Required parameter is null.", "profile.Credentials"); } if (profile.Encoding == null) { throw new ArgumentException("Required parameter is null.", "profile.Encoding"); } // copy over the profile properties to this instance Host = profile.Host; Credentials = profile.Credentials; EncryptionMode = profile.Encryption; SslProtocols = profile.Protocols; DataConnectionType = profile.DataConnection; Encoding = profile.Encoding; if (profile.Timeout != 0) { ConnectTimeout = profile.Timeout; ReadTimeout = profile.Timeout; DataConnectionConnectTimeout = profile.Timeout; DataConnectionReadTimeout = profile.Timeout; } if (SocketPollInterval != 0) { SocketPollInterval = profile.SocketPollInterval; } if (RetryAttempts != 0) { RetryAttempts = profile.RetryAttempts; } }