示例#1
0
        /// <summary>
        /// Extract <c>DateTime</c> information from an <c>Easy</c> object.
        /// </summary>
        /// <param name="info">One of the values in the
        /// <see cref="CURLINFO"/> enumeration. In this case, it must
        /// specifically be <see cref="CURLINFO.CURLINFO_FILETIME"/>.
        /// </param>
        /// <param name="dt">Reference to a <c>DateTime</c> value.</param>
        /// <returns>The <see cref="CURLcode"/> obtained from the internal
        /// call to <c>curl_easy_getinfo()</c>.
        /// </returns>
        /// <exception cref="System.NullReferenceException">This is thrown if
        /// the native <c>CURL*</c> handle wasn't created successfully.</exception>
        public CURLcode GetInfo(CURLINFO info, ref DateTime dt)
        {
            EnsureHandle();
            CURLcode retCode = CURLcode.CURLE_OK;

            if (info != CURLINFO.CURLINFO_FILETIME)
            {
                return(CURLcode.CURLE_BAD_FUNCTION_ARGUMENT);
            }

            int yy = 0, mm = 0, dd = 0, hh = 0, mn = 0, ss = 0;

            retCode = External.curl_easy_getinfo_time(m_pCURL, info, ref yy, ref mm, ref dd, ref hh, ref mn, ref ss);
            if (retCode == CURLcode.CURLE_OK)
            {
                dt = new DateTime(yy, mm, dd, hh, mn, ss);
            }
            return(retCode);
        }