Ejemplo n.º 1
0
        /// <summary>
        /// Asynchronusly retrieve a SHA512 hash. The XSHA512 command is non-standard
        /// and not guaranteed to work.
        /// </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 BeginGetXSHA512(this FtpClient client, string path, AsyncCallback callback, object state) {
            AsyncGetXSHA512 func = new AsyncGetXSHA512(client.GetXSHA512);
            IAsyncResult ar = func.BeginInvoke(path, callback, state); ;
            
            lock (m_asyncmethods) {
                m_asyncmethods.Add(ar, func);
            }

            return ar;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Begins an asynchronous operation to retrieve a SHA512 hash. The XSHA512 command is non-standard
        /// and not guaranteed to work.
        /// </summary>
        /// <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 BeginGetXSHA512(string path, AsyncCallback callback, object state)
        {
            AsyncGetXSHA512 func = new AsyncGetXSHA512(GetXSHA512);
            IAsyncResult ar      = func.BeginInvoke(path, callback, state);;

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

            return(ar);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Ends an asynchronous call to <see cref="BeginGetXSHA512"/>
        /// </summary>
        /// <param name="ar">IAsyncResult returned from <see cref="BeginGetXSHA512"/></param>
        /// <returns>The SHA-512 hash of the specified file.</returns>
        public string EndGetXSHA512(IAsyncResult ar)
        {
            AsyncGetXSHA512 func = null;

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

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

            return(func.EndInvoke(ar));
        }