/// <summary>
        /// 根据XML信息填充实实体
        /// </summary>
        /// <typeparam name="T">MessageBase为基类的类型,Response和Request都可以</typeparam>
        /// <param name="entity">实体</param>
        /// <param name="doc">XML</param>
        public static void FillEntityWithXml <T>(this T entity, XDocument doc) where T : /*MessageBase*/ class, new()
        {
            entity = entity ?? new T();
            var root = doc.Root;

            var props = entity.GetType().GetProperties();

            foreach (var prop in props)
            {
                var propName = prop.Name;
                if (root.Element(propName) != null)
                {
                    if (prop.PropertyType == typeof(DateTime))
                    {
                        prop.SetValue(entity, WeixinTimestampHelper.ToLocalTime(root.Element(propName).Value), null);
                    }
                    else if (prop.PropertyType == typeof(Boolean) && (propName == "FuncFlag"))
                    {
                        prop.SetValue(entity, root.Element(propName).Value == "1", null);
                    }
                    else if (prop.PropertyType == typeof(Int32))
                    {
                        prop.SetValue(entity, int.Parse(root.Element(propName).Value), null);
                    }
                    else if (prop.PropertyType == typeof(Int64))
                    {
                        prop.SetValue(entity, long.Parse(root.Element(propName).Value), null);
                    }
                    else if (prop.PropertyType == typeof(Decimal))
                    {
                        prop.SetValue(entity, decimal.Parse(root.Element(propName).Value), null);
                    }
                    else if (prop.PropertyType == typeof(Double))
                    {
                        prop.SetValue(entity, double.Parse(root.Element(propName).Value), null);
                    }
                    else if (prop.PropertyType == typeof(ReceivedMsgType))
                    {
                        //已设为只读
                        //prop.SetValue(entity, MsgTypeHelper.GetRequestMsgType(root.Element(propName).Value), null);
                    }
                    else if (prop.PropertyType == typeof(ResponseMsgType))
                    {
                        //已设为只读
                        //prop.SetValue(entity, MsgTypeHelper.GetResponseMsgType(root.Element(propName).Value), null);
                    }
                    else if (prop.PropertyType == typeof(ReceivedEventType))
                    {
                        //已设为只读
                        //prop.SetValue(entity, EventHelper.GetEventType(root.Element(propName).Value), null);
                    }
                    else if (prop.PropertyType == typeof(List <Article>))
                    {
                        //var genericArguments = prop.PropertyType.GetGenericArguments();
                        //if (genericArguments[0].Name == "Article")//ResponseMessageNews适用
                        {
                            //文章下属节点item
                            List <Article> articles = new List <Article>();
                            foreach (var item in root.Element(propName).Elements("item"))
                            {
                                var article = new Article();
                                FillEntityWithXml(article, new XDocument(item));
                                articles.Add(article);
                            }
                            prop.SetValue(entity, articles, null);
                        }
                    }
                    else if (prop.PropertyType == typeof(Music))
                    {
                        Music music = new Music();
                        FillEntityWithXml(music, new XDocument(root.Element(propName)));
                        prop.SetValue(entity, music, null);
                    }
                    else if (prop.PropertyType == typeof(Image))
                    {
                        Image image = new Image();
                        FillEntityWithXml(image, new XDocument(root.Element(propName)));
                        prop.SetValue(entity, image, null);
                    }
                    else if (prop.PropertyType == typeof(Voice))
                    {
                        Voice voice = new Voice();
                        FillEntityWithXml(voice, new XDocument(root.Element(propName)));
                        prop.SetValue(entity, voice, null);
                    }
                    else if (prop.PropertyType == typeof(Video))
                    {
                        Video video = new Video();
                        FillEntityWithXml(video, new XDocument(root.Element(propName)));
                        prop.SetValue(entity, video, null);
                    }
                    else
                    {
                        prop.SetValue(entity, root.Element(propName).Value, null);
                    }
                }
            }
        }