Hishop.Weixin.MP/Util/EntityHelper.cs
(开头部分) 5KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
namespace Hishop.Weixin.MP.Util
{
using Hishop.Weixin.MP.Domain;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Xml.Linq;
public static class EntityHelper
{
public static XDocument ConvertEntityToXml<T>(T entity) where T: class, new()
{
if (entity == null)
{
}
entity = Activator.CreateInstance<T>();
XDocument document = new XDocument();
document.Add(new XElement("xml"));
XElement root = document.Root;
List<string> list = new string[] { "ToUserName", "FromUserName", "CreateTime", "MsgType", "Content", "ArticleCount", "Articles", "FuncFlag", "Title ", "Description ", "PicUrl", "Url" }.ToList<string>();
Func<string, int> orderByPropName = new Func<string, int>(list.IndexOf);
foreach (PropertyInfo info in (from p in entity.GetType().GetProperties()
orderby orderByPropName(p.Name)
select p).ToList<PropertyInfo>())
{
DateTime time;
string name = info.Name;
if (name == "Articles")
{
XElement content = new XElement("Articles");
List<Article> list3 = info.GetValue(entity, null) as List<Article>;
foreach (Article article in list3)
{
IEnumerable<XElement> enumerable = ConvertEntityToXml<Article>(article).Root.Elements();
content.Add(new XElement("item", enumerable));
}
root.Add(content);
}
else
{
string str2 = info.PropertyType.Name;
if (str2 == null)
{
goto Label_0328;
}
if (!(str2 == "String"))
{
if (str2 == "DateTime")
{
goto Label_0252;
}
if (str2 == "Boolean")
{
goto Label_028A;
}
if (str2 == "ResponseMsgType")
{
goto Label_02D0;
}
后面还有 88 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。
