コード例 #1
0
        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;
        }
コード例 #2
0
        /// <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);
        }
コード例 #3
0
        /// <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();
        }
コード例 #4
0
        /// <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);
        }
コード例 #5
0
        /// <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();
        }
コード例 #6
0
 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;
             }
         });
     }
 }
コード例 #7
0
        /// <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;
            }
        }