예제 #1
0
        /// <summary>
        /// 解析响应字符串
        /// </summary>
        /// <param name="responseContent">响应字符串</param>
        /// <param name="errorMessage">返回错误消息</param>
        /// <returns>返回多媒体上传结果</returns>
        private static MultiMediaUploadResult ParseResult(string responseContent, out ErrorMessage errorMessage)
        {
            MultiMediaUploadResult result = null;

            if (string.IsNullOrWhiteSpace(responseContent))
            {
                errorMessage = new ErrorMessage(ErrorMessage.ExceptionCode, "上传失败。");
            }
            else if (ErrorMessage.IsErrorMessage(responseContent))
            {
                errorMessage = ErrorMessage.Parse(responseContent);
            }
            else
            {
                if (MultiMediaUploadResult.TryParse(responseContent, out result))
                {
                    errorMessage = new ErrorMessage(ErrorMessage.SuccessCode, "上传成功。");
                }
                else
                {
                    errorMessage = new ErrorMessage(ErrorMessage.ExceptionCode, "解析多媒体上传结果失败。");
                }
            }
            return(result);
        }
예제 #2
0
        /// <summary>
        /// 尝试从JSON字符串解析多媒体上传结果
        /// </summary>
        /// <param name="json">JSON字符串</param>
        /// <param name="msg">如果解析成功,返回多媒体上传结果;否则,返回null。</param>
        /// <returns>返回是否解析成功</returns>
        public static bool TryParse(string json, out MultiMediaUploadResult result)
        {
            bool success = false;

            result = null;
            try
            {
                result  = Parse(json);
                success = true;
            }
            catch { }
            return(success);
        }