private static WorkResponseMessageBase CreateFromRequestMessage(IWorkRequestMessageBase requestMessage, ResponseMsgType msgType)
        {
            //注意:SDK 内部此方法仍然是重要的最终执行的方法,只是提供了简化的重写方法,不建议外部直接调用。

            WorkResponseMessageBase responseMessage = null;

            try
            {
                switch (msgType)
                {
                case ResponseMsgType.Text:
                    responseMessage = new ResponseMessageText();
                    break;

                case ResponseMsgType.News:
                    responseMessage = new ResponseMessageNews();
                    break;

                case ResponseMsgType.Image:
                    responseMessage = new ResponseMessageImage();
                    break;

                case ResponseMsgType.Voice:
                    responseMessage = new ResponseMessageVoice();
                    break;

                case ResponseMsgType.Video:
                    responseMessage = new ResponseMessageVideo();
                    break;

                case ResponseMsgType.MpNews:
                    responseMessage = new ResponseMessageMpNews();
                    break;

                case ResponseMsgType.NoResponse:
                    responseMessage = new WorkResponseMessageNoResponse();
                    break;

                default:
                    throw new UnknownRequestMsgTypeException(string.Format("ResponseMsgType没有为 {0} 提供对应处理程序。", msgType), new ArgumentOutOfRangeException());
                }

                responseMessage.ToUserName   = requestMessage.FromUserName;
                responseMessage.FromUserName = requestMessage.ToUserName;
                responseMessage.CreateTime   = SystemTime.Now;               //使用当前最新时间
            }
            catch (Exception ex)
            {
                throw new WeixinException("CreateFromRequestMessage过程发生异常", ex);
            }

            return(responseMessage);
        }
        /// <summary>
        /// 从返回结果XML转换成IResponseMessageBase实体类
        /// </summary>
        /// <param name="xml">返回给服务器的Response Xml</param>
        /// <returns></returns>
        public static IWorkResponseMessageBase CreateFromResponseXml(string xml)
        {
            try
            {
                if (string.IsNullOrEmpty(xml))
                {
                    return(null);
                }

                var doc = XDocument.Parse(xml);
                WorkResponseMessageBase responseMessage = null;
                var msgType = (ResponseMsgType)Enum.Parse(typeof(ResponseMsgType), doc.Root.Element("MsgType").Value, true);
                switch (msgType)
                {
                case ResponseMsgType.Text:
                    responseMessage = new ResponseMessageText();
                    break;

                case ResponseMsgType.Image:
                    responseMessage = new ResponseMessageImage();
                    break;

                case ResponseMsgType.Voice:
                    responseMessage = new ResponseMessageVoice();
                    break;

                case ResponseMsgType.Video:
                    responseMessage = new ResponseMessageVideo();
                    break;

                case ResponseMsgType.News:
                    responseMessage = new ResponseMessageNews();
                    break;

                case ResponseMsgType.MpNews:
                    responseMessage = new ResponseMessageMpNews();
                    break;

                case ResponseMsgType.NoResponse:
                    responseMessage = new WorkResponseMessageNoResponse();
                    break;
                }

                responseMessage.FillEntityWithXml(doc);
                return(responseMessage);
            }
            catch (Exception ex)
            {
                throw new WeixinException("ResponseMessageBase.CreateFromResponseXml<T>过程发生异常!" + ex.Message, ex);
            }
        }