示例#1
0
        /// <summary>
        /// Asynchronusly retrieve a checksum of the specified file. This feature
        /// is non-standard.
        /// </summary>
        /// <param name="client">FtpClient Object</param>
        /// <param name="path">Full or relative path to remote file</param>
        /// <param name="callback">AsyncCallback</param>
        /// <param name="state">State Object</param>
        /// <returns>IAsyncResult</returns>
        public static IAsyncResult BeginGetChecksum(this FtpClient client, string path, AsyncCallback callback, object state) {
            AsyncGetChecksum func = new AsyncGetChecksum(client.GetChecksum);
            IAsyncResult ar = func.BeginInvoke(path, callback, state); ;

            lock (m_asyncmethods) {
                m_asyncmethods.Add(ar, func);
            }

            return ar;
        }
示例#2
0
        /// <summary>
        /// Asynchronusly retrieve a checksum of the specified file. This feature
        /// is non-standard.
        /// </summary>
        /// <param name="client">FtpClient Object</param>
        /// <param name="path">Full or relative path to remote file</param>
        /// <param name="callback">AsyncCallback</param>
        /// <param name="state">State Object</param>
        /// <returns>IAsyncResult</returns>
        public static IAsyncResult BeginGetChecksum(this FtpClient client, string path, AsyncCallback callback, object state)
        {
            AsyncGetChecksum func = new AsyncGetChecksum(client.GetChecksum);
            IAsyncResult     ar   = func.BeginInvoke(path, callback, state);;

            lock (m_asyncmethods) {
                m_asyncmethods.Add(ar, func);
            }

            return(ar);
        }
示例#3
0
        /// <summary>
        /// Begins an asynchronous operation to retrieve a checksum of the given file using a checksum method that the server supports, if any.
        /// </summary>
        /// <remarks>
        /// The algorithm used goes in this order:
        /// 1. HASH command; server preferred algorithm. See <see cref="FtpClient.SetHashAlgorithm"/>
        /// 2. MD5 / XMD5 / MMD5 commands
        /// 3. XSHA1 command
        /// 4. XSHA256 command
        /// 5. XSHA512 command
        /// 6. XCRC command
        /// </remarks>
        /// <param name="path">Full or relative path to remote file</param>
        /// <param name="callback">AsyncCallback</param>
        /// <param name="state">State Object</param>
        /// <returns>IAsyncResult</returns>
        public IAsyncResult BeginGetChecksum(string path, AsyncCallback callback,
                                             object state)
        {
            var func = new AsyncGetChecksum(GetChecksum);
            IAsyncResult ar;

            lock (m_asyncmethods) {
                ar = func.BeginInvoke(path, callback, state);
                m_asyncmethods.Add(ar, func);
            }

            return(ar);
        }
示例#4
0
        /// <summary>
        /// Ends an asynchronous call to <see cref="BeginGetChecksum"/>
        /// </summary>
        /// <param name="ar">IAsyncResult returned from <see cref="BeginGetChecksum"/></param>
        /// <returns><see cref="FtpHash"/> object containing the value and algorithm. Use the <see cref="FtpHash.IsValid"/> property to
        /// determine if this command was successful. <see cref="FtpCommandException"/>s can be thrown from
        /// the underlying calls.</returns>
        public FtpHash EndGetChecksum(IAsyncResult ar)
        {
            AsyncGetChecksum func = null;

            lock (m_asyncmethods) {
                if (!m_asyncmethods.ContainsKey(ar))
                {
                    throw new InvalidOperationException("The specified IAsyncResult was not found in the collection.");
                }

                func = (AsyncGetChecksum)m_asyncmethods[ar];
                m_asyncmethods.Remove(ar);
            }

            return(func.EndInvoke(ar));
        }