惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
The Blog of Author Tim Ferriss
Know Your Adversary
Know Your Adversary
P
Palo Alto Networks Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
K
Kaspersky official blog
L
LINUX DO - 热门话题
P
Proofpoint News Feed
P
Privacy & Cybersecurity Law Blog
Google DeepMind News
Google DeepMind News
Attack and Defense Labs
Attack and Defense Labs
Cisco Talos Blog
Cisco Talos Blog
AI
AI
L
LINUX DO - 最新话题
H
Heimdal Security Blog
Hacker News: Ask HN
Hacker News: Ask HN
Webroot Blog
Webroot Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
The GitHub Blog
The GitHub Blog
I
Intezer
Blog — PlanetScale
Blog — PlanetScale
有赞技术团队
有赞技术团队
S
Securelist
博客园_首页
IT之家
IT之家
Schneier on Security
Schneier on Security
博客园 - 叶小钗
罗磊的独立博客
WordPress大学
WordPress大学
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
MongoDB | Blog
MongoDB | Blog
P
Proofpoint News Feed
阮一峰的网络日志
阮一峰的网络日志
A
Arctic Wolf
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
W
WeLiveSecurity
The Register - Security
The Register - Security
D
DataBreaches.Net
S
Security @ Cisco Blogs
Security Archives - TechRepublic
Security Archives - TechRepublic
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
腾讯CDC
Recorded Future
Recorded Future
NISL@THU
NISL@THU
N
News and Events Feed by Topic
T
Tailwind CSS Blog
N
News and Events Feed by Topic
Cyberwarzone
Cyberwarzone
T
Tor Project blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com

博客园 - 牟向阳

Implementing SQL Server Row and Cell Level Security Daily English 你知道你的後照鏡調錯了嗎?原來裡面隱藏著視線死角! Silverlight Freezing & Crash Silverlight 中实现Service同步调用 Silverlight:获取ContentTemplate中的命名控件 silverlight 4常用的多线程技术 推荐几款Silverlight Tools【转载】 Emit Vs CodeDom Custom DataContractSerializerOperationBehavior SQL Service查询分析 WPF&Silverlight精髓 支持定位当前页,自定义排序的分页SQL(拒绝动态SQL) WCF学习经验分享,如何更好地学习WCF? 后台管理界面收集 两个使用的Ajax Demo 自学面向对象 发几个有价值的.net源码 我是如何带领团队开发项目的
一个配置文件的Mapping
牟向阳 · 2011-05-06 · via 博客园 - 牟向阳

1. 需要Mapping的Xml结构

<?xml version="1.0" encoding="utf-8"?>
<Requestes>
<Request name="RequestA" formname="LanguageUI" serviceurl="http://MyComputer/LanguageService" httpmethod="POST" targetui="Settings->LanuageSetting">
<Reference name="ClassA">
<Property name="DateFrom" type="DateTime?" />
<Property name="DateTo" type="DateTime?" />
</Reference>
</Request>
<Request name="RequestB" formname="ImageShowUI" serviceurl="http://MyComputer/ImageService" httpmethod="POST" targetui="Settings->Images">
<Reference name="ClassB">
<Property name="Top" type="int" />
</Reference>
</Request>
</Requestes>

2. Mapping到的类结构

public class PropertyInfo
{
public string PropertyName
{
get;
set;
}
public string PropertyType
{
get;
set;
}
}
public class DynamicEntity
{
public string Name
{
get;
set;
}
public string ServiceURL
{
get;
set;
}
public string TargetUI
{
get;
set;
}
public List<PropertyInfo> SimplePropertyList { get; set; }
public Dictionary<string, List<PropertyInfo>> CollectivePropertyList { get; set; }
public List<RefenceInfo> RefenceList
{
get;
set;
}
public string HttpMehtod
{
get;
set;
}
public string FormName
{
get;
set;
}
}
public class RefenceInfo
{
public string Key
{
get;
set;
}
public List<PropertyInfo> SimplePropertyList { get; set; }
public Dictionary<string, List<PropertyInfo>> CollectivePropertyList { get; set; }
public List<RefenceInfo> RefenceList { get; set; }
}

 3. Mapping的方法

public static List<DynamicEntity> Generate(string xmlPath, string formName)
{
XElement main
= XElement.Load(xmlPath);return
(from c
in main.Elements("Request")
where c.Attribute("formname").Value == formName
select
new DynamicEntity
{
Name
= c.Attribute("name").Value,
ServiceURL
= c.Attribute("serviceurl").Value,
TargetUI
= c.Attribute("targetui").Value,
HttpMehtod
= c.Attribute("httpmethod").Value,
FormName
= c.Attribute("formname").Value,
SimplePropertyList
= c.Elements("Property").Where(p => p.Attribute("type").Value.Trim().ToLower() != "list").Select(p => new PropertyInfo { PropertyName = p.Attribute("name").Value, PropertyType = p.Attribute("type").Value }).ToList(),
CollectivePropertyList
= CollectivePropertyList(c.Elements("Property").Where(p => p.Attribute("type").Value.Trim().ToLower() == "list")),
RefenceList
= TopRefenceList(c.Elements("Reference"))
}).ToList
<DynamicEntity>();
}