Exemple #1
0
 internal static extern void nim_nos_upload_ex(
     [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8StringMarshaler))] string local_file,
     [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8StringMarshaler))] string json_extension,
     UploadCb res_cb, IntPtr res_user_data,
     UploadPrgCb prg_cb, IntPtr prg_user_data,
     UploadSpeedCb speed_cb, IntPtr speed_user_data,
     UploadInfoCb info_cb, IntPtr info_user_data);
        /// <summary>
        /// 上传资源(扩展)
        /// </summary>
        /// <param name="localFile">本地文件的完整路径</param>
        /// <param name="param">扩展参数</param>
        /// <param name="resCb"></param>
        /// <param name="resData"></param>
        /// <param name="prgCb"></param>
        /// <param name="prgData"></param>
        /// <param name="speedCb"></param>
        /// <param name="speedData"></param>
        /// <param name="infoCb"></param>
        /// <param name="infoData"></param>
        public static void UploadEx(string localFile,
                                    HttpExtendedParameters param,
                                    UploadCb resCb, IntPtr resData,
                                    UploadPrgCb prgCb, IntPtr prgData,
                                    UploadSpeedCb speedCb, IntPtr speedData,
                                    UploadInfoCb infoCb, IntPtr infoData)
        {
            CallbackDataPair resPair   = new CallbackDataPair(resCb, resData);
            CallbackDataPair prgPair   = new CallbackDataPair(prgCb, prgData);
            CallbackDataPair speedPair = new CallbackDataPair(speedCb, speedData);
            CallbackDataPair infoPair  = new CallbackDataPair(infoCb, infoData);

            NosNativeMethods.nim_nos_upload_ex(localFile,
                                               param != null ? param.Serialize() : string.Empty,
                                               UploadCallbackEx, resPair.ToIntPtr(),
                                               UploadPrgCallbackEx, prgPair.ToIntPtr(),
                                               UploadSpeedCallbackEx, speedPair.ToIntPtr(),
                                               UploadInfoCallbackEx, infoPair.ToIntPtr());
        }